locked
How detect shift key release when both shift keys are pressed

    Question

  • Why is no event fired when a shift key is released if both shift keys were pressed?

    1. Press left shift - keydown event
    2. Press right shift - keydown event
    3. Release left shift - no event
    4. Release right shift - keyup event

    So, we have two keydown events and just one keyup event.

    Wednesday, February 11, 2015 12:57 PM

Answers

  • I think that the two shift keys are logically the same key and both provide VK_SHIFT. Since they are the same key, it's still down when the left key goes up and so no up fires. This behavour is inherited from the underlying keyboard input system and is the same as you'll see if you handle WM_KEYDOWN and WM_KEYUP in a Win32 app.

    You can differentiate the VirtualKey.LShift and RShift keys with CoreWindow.GetKeyState() or GetAsyncKeyState(), but there isn't a direct way to catch your state #3 in action.

    Wednesday, February 11, 2015 4:31 PM
    Owner
  • You can differentiate the VirtualKey.LShift and RShift keys with CoreWindow.GetKeyState() or GetAsyncKeyState(),
    Monday, February 16, 2015 3:15 PM
    Owner

All replies

  • I think that the two shift keys are logically the same key and both provide VK_SHIFT. Since they are the same key, it's still down when the left key goes up and so no up fires. This behavour is inherited from the underlying keyboard input system and is the same as you'll see if you handle WM_KEYDOWN and WM_KEYUP in a Win32 app.

    You can differentiate the VirtualKey.LShift and RShift keys with CoreWindow.GetKeyState() or GetAsyncKeyState(), but there isn't a direct way to catch your state #3 in action.

    Wednesday, February 11, 2015 4:31 PM
    Owner
  • Thanks for your reply. What is the indirect way (or how to avoid firing the second keydown event) ?

    Monday, February 16, 2015 10:51 AM
  • You can differentiate the VirtualKey.LShift and RShift keys with CoreWindow.GetKeyState() or GetAsyncKeyState(),
    Monday, February 16, 2015 3:15 PM
    Owner