Answered by:
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 eventSo, 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.
- Proposed as answer by Herro wongMicrosoft contingent staff, Moderator Monday, February 23, 2015 1:24 AM
- Marked as answer by Herro wongMicrosoft contingent staff, Moderator Tuesday, February 24, 2015 1:33 AM
Wednesday, February 11, 2015 4:31 PMModerator -
You can differentiate the VirtualKey.LShift and RShift keys with CoreWindow.GetKeyState() or GetAsyncKeyState(),
- Proposed as answer by Herro wongMicrosoft contingent staff, Moderator Monday, February 23, 2015 1:24 AM
- Marked as answer by Herro wongMicrosoft contingent staff, Moderator Tuesday, February 24, 2015 1:33 AM
Monday, February 16, 2015 3:15 PMModerator
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.
- Proposed as answer by Herro wongMicrosoft contingent staff, Moderator Monday, February 23, 2015 1:24 AM
- Marked as answer by Herro wongMicrosoft contingent staff, Moderator Tuesday, February 24, 2015 1:33 AM
Wednesday, February 11, 2015 4:31 PMModerator -
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(),
- Proposed as answer by Herro wongMicrosoft contingent staff, Moderator Monday, February 23, 2015 1:24 AM
- Marked as answer by Herro wongMicrosoft contingent staff, Moderator Tuesday, February 24, 2015 1:33 AM
Monday, February 16, 2015 3:15 PMModerator