Closed Bug 1138918 Opened 10 years ago Closed 10 years ago

Unconventional keycode for volume button events

Categories

(Firefox OS Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: felix.klee, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0 Build ID: 20150302004030 Steps to reproduce: On my Flame with the latest Firefox OS 2.2.0.0-prerelease, started my app Trigger, then from WebIDE in Firefox Dev. Ed., I ran in the console: window.addEventListener('keydown', function (e) { console.log(e); }); Actual results: When pressing the volume keys, I got: keydown { target: <body>, key: "VolumeUp", charCode: 0, keyCode: 183 } keydown { target: <body>, key: "VolumeDown", charCode: 0, keyCode: 182 } Expected results: I would expect key codes 175 and 174, which are the key codes used on Android devices, and which are emitted for example by Bluetooth selfie sticks.
This is defined in https://bugzilla.mozilla.org/show_bug.cgi?id=674739#c7 Do you mean that 175 and 174 are used on Android devices by other browsers? Anyway I think the constants KeyboardEvent.DOM_VK_VOLUME_UP and KeyboardEvent.DOM_VK_VOLUME_DOWN should be used instead of numbers here.
Just realized that there is a difference between scan code and key codes ("virtual key codes" on Windows). The scan code is what the hardware generates, whereas the key code is what the OS hands down to applications. 175 and 174 are key codes. The corresponding scan codes on Android are 114 (volume down) and 115 (volume up). This can be checked e.g. with the Android app "KeyEvent Display". When I connect a Bluetooth shutter device to my Android device, then it also sends these key codes. This is because on modern Android devices one can trigger the camera shutter or its zoom by using the volume buttons. It is important that B2G also maps 114 and 115 to volume down and up. Maybe that's already the case. I don't know how to check it. Is there perhaps a way to display scan codes in the log? Sorry for the confusion.
you could use the utility |adb shell getevent| to output the input events and their codes
`adb shell getevent` gives for volume-down on my Flame with 18D and 3.0.0.0-prerelease: /dev/input/event5: 0001 0072 00000001 /dev/input/event5: 0000 0000 00000000 /dev/input/event5: 0001 0072 00000000 /dev/input/event5: 0000 0000 00000000 0x72 is 114, which seems to be the scan code, and which matches Android. For volume-up I get 0x73 = 115, again matching Android. Looks good, so I close this bug as resolved. I should have been aware of the difference between scan codes and key codes. After all I dabbled with building a keyboard controller a while ago, for: http://www.thingiverse.com/thing:433339
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.