Added modifier keys resilience

Fixed a bug where algorithm was disrupting modifier key functionalities.