locked
How to tell Right shift key down from left shift key down

    Question

  • I have an app subscribing to CoreWindow KeyDown event.

    The event args->VirtualKey always giving me 16(Shift) regardless I press left shift or right shift.

    How to tell the two from codes?

    Monday, January 12, 2015 3:30 PM

Answers

  • When you get a KeyDown for VirtualKey::Shift call CoreWindow::GetKeyState(VirtualKey::LeftShift) or (VirtualKey::RightShift) to differentiate between the keys.
    • Marked as answer by hereafter Tuesday, January 13, 2015 3:21 AM
    Monday, January 12, 2015 4:20 PM
    Moderator
  • From the eventing point of view they're the same key. There is no way to get a second KeyDown event when the same virtual key is pressed, even if it's physically a different key.

    • Marked as answer by hereafter Tuesday, January 13, 2015 4:24 AM
    Tuesday, January 13, 2015 3:49 AM
    Moderator

All replies

  • When you get a KeyDown for VirtualKey::Shift call CoreWindow::GetKeyState(VirtualKey::LeftShift) or (VirtualKey::RightShift) to differentiate between the keys.
    • Marked as answer by hereafter Tuesday, January 13, 2015 3:21 AM
    Monday, January 12, 2015 4:20 PM
    Moderator
  • This is a follow up question.

    I have a use case i need to monitor Left shift down and Right down seperately.

    When i hold down left shift key a KeyDown event is fired with Shift as its virtual key,

    then i press down right shift key before i let left shift key go, no event is fired.

    Is there any way to get around this?

    Tuesday, January 13, 2015 3:24 AM
  • From the eventing point of view they're the same key. There is no way to get a second KeyDown event when the same virtual key is pressed, even if it's physically a different key.

    • Marked as answer by hereafter Tuesday, January 13, 2015 4:24 AM
    Tuesday, January 13, 2015 3:49 AM
    Moderator