Issue
For a given Android project, during development, working with the Android emulator, I use the arrow keys on my physical keyboard a lot in order to navigate between input elements on the screen. If the device is in portrait orientation, this works as expected, but if I rotate the device to landscape, the keys get mapped to incorrect key codes. Right Key: KEYCODE_DPAD_DOWN, Down Key: KEYCODE_DPAD_LEFT, Left Key: KEYCODE_DPAD_UP, Up Key: KEYCODE_DPAD_RIGHT.
There seems to be an underlying assumption that the keyboard is rotated as well, and keys are transposed to account for this rotation. Is there any setting that allows either to deactivate the behaviour completely, or at least configure it so that landscape orientation is considered as a base?
Solution
Since I fought with the same issue today, let me share with you how I fix it :
On AVD details, you can edit the "Startup orientation". If I select "Portrait", it fixes the problem.
Of course, if I then rotate to landscape while started on Portrait, the problem occurs on this orientation.
I didn't find a way to get the correct values whatever is the orientation. I don't know if it's linked to how the emulator "rotates" the screen or if the emulator driver misses the keyboard.orientationAware settings.
More informations on it at https://source.android.com/devices/input/keyboard-devices
Answered By - KanedaFr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.