opencv handling arrow keys with waitKey() function
Use waitKeyEx()
function instead. As the documentation says:
Similar to waitKey(), but returns full key code.
Key code is implementation specific and depends on used backend: QT/GTK/Win32
On my system it gives: Left: 2424832 Up: 2490368 Right: 2555904 Down: 2621440
Although there are many online sources saying waitKey()
works with arrows, it didn't return proper key codes on my Windows system either (always returned 0). Guess that is also implementation specific. Maybe because waitKey()
returns ASCII-codes, but arrow keys don't have them (as explained here).
Note that this depends on version, on windows with 3.0 waitKey() gave full key codes, but when I changed to 3.3, it suddenly returned 0 for arrow keys.