Skip to content

Instantly share code, notes, and snippets.

@GalvinGao
Created June 19, 2019 08:21
Show Gist options
  • Save GalvinGao/83ae9530434b11b0c203138025789f46 to your computer and use it in GitHub Desktop.
Save GalvinGao/83ae9530434b11b0c203138025789f46 to your computer and use it in GitHub Desktop.
Mapping of JavaScript KeyCode to Android KeyCode (adb shell input keyevent)

Mapping

[!] Notice that there's three special key codes: __Power, __VolumeUp and __VolumeDown.

Additional KeyCode

{ "@": 77 }  // use keyevent.key === '@' to detect if the user is inputting an '@' character
const keyCodeToAndroid = {
"Digit0": 7,
"Digit1": 8,
"Digit2": 9,
"Digit3": 10,
"Digit4": 11,
"Digit5": 12,
"Digit6": 13,
"Digit7": 14,
"Digit8": 15,
"Digit9": 16,
"Numpad0": 7,
"Numpad1": 8,
"Numpad2": 9,
"Numpad3": 10,
"Numpad4": 11,
"Numpad5": 12,
"Numpad6": 13,
"Numpad7": 14,
"Numpad8": 15,
"Numpad9": 16,
"Star": 17,
"Pound": 18,
"__VolumeUp": 24,
"__VolumeDown": 25,
"__Power": 26,
"KeyA": 29,
"KeyB": 30,
"KeyC": 31,
"KeyD": 32,
"KeyE": 33,
"KeyF": 34,
"KeyG": 35,
"KeyH": 36,
"KeyI": 37,
"KeyJ": 38,
"KeyK": 39,
"KeyL": 40,
"KeyM": 41,
"KeyN": 42,
"KeyO": 43,
"KeyP": 44,
"KeyQ": 45,
"KeyR": 46,
"KeyS": 47,
"KeyT": 48,
"KeyU": 49,
"KeyV": 50,
"KeyW": 51,
"KeyX": 52,
"KeyY": 53,
"KeyZ": 54,
"Comma": 55,
"Period": 56,
"AltLeft": 57,
"AltRight": 58,
"ShiftLeft": 59,
"ShiftRight": 60,
"Tab": 61,
"Space": 62,
"Enter": 66,
"Delete": 67,
"Minus": 69,
"Equal": 70,
"BracketLeft": 71,
"BracketRight": 72,
"Backslash": 73,
"Semicolon": 74,
"Quote": 75,
"Slash": 76
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment