Alt key skips KeyDown, KeyUp events

  Kiến thức lập trình

If I have a key down and then I touch the Alt key, the KeyUp event doesn’t fire for the key I had down until the next time I hit the key that’s repeating i.e. “aaaaaaaaa…”. It’s like when you don’t use the deactivate or lost focus events and you click away, the key you were holding continues.

I’ve tried using preview key down and preview key up to catch Alt key presses. I’ve even tried having every key be released if the Alt key is pressed, but there was a delay between pressing the Alt key and the other key stopping.

I don’t necessarily want to disable things like Alt+F4. I’m deliberately not using the Alt key for any purpose in my app. But a user might hit the Alt key and have this issue.

I’ve tried a few other things I’ve found on here but others are above my head.

I do not want to check IsKeyDown for every key if it can be helped.

LEAVE A COMMENT