0

Windows 10 x64. opencv 4.0.1

I've been using waitKey, and now under opencv 4.0.1, waitKeyEx successfully for the 4 arrow keys but the returned code from waitKeyEx apparently doesn't change when I press them simultaneously with the SHIFT or CTRL keys (0x00250000 - Left, 0x00260000 - Up, etc returned from waitKeyEx() regardless of shift or CTRL being pressed or not )

  • 1
    show your code, how you do it atm. Probably those modifiers like shift/ctrl are assigned to fixed bits and if multiple ones are pressed, you'll have to check for those bits instead of total number's equality. – Micka Feb 23 '19 at 22:29

1 Answers1

0

It seems that calling GetKeyState after waitKeyEx() returns will do. I've tried it for shift via

int nRet = GetKeyState(VK_SHIFT);

(called right after the call to waitKeyEx(), which returns -127 if the left shift key was pressed, -128 right, 0 neither. I haven't tried CNTRL. I see in http://forums.codeguru.com/showthread.php?447587-Detecting-if-Control-or-Shift-key-was-down-when-key-pressed that it has a caveat that it isn't real time but empirically it seems to do the trick for waitKeyEx()

user202729
  • 3,358
  • 3
  • 25
  • 36