MCPcopy Index your code
hub / github.com/tiny-pilot/tinypilot / keystrokeToCanonicalCode

Function keystrokeToCanonicalCode

app/static/js/keycodes.js:4–20  ·  view source on GitHub ↗
(keystroke)

Source from the content-addressed store, hash-verified

2 * @param {KeyboardEvent} keystroke - https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
3 */
4export function keystrokeToCanonicalCode(keystroke) {
5 // Some keyboards send RightAlt/AltGraph as LeftControl then Alt, where the
6 // Alt key has a blank code.
7 if (keystroke.key === "Alt" && keystroke.code === "") {
8 return "AltRight";
9 }
10
11 // Firefox calls it `OS...` instead of `Meta...`.
12 if (keystroke.code === "OSLeft") {
13 return "MetaLeft";
14 }
15 if (keystroke.code === "OSRight") {
16 return "MetaRight";
17 }
18
19 return keystroke.code;
20}
21
22export function isModifierCode(code) {
23 const modifierCodes = [

Callers 4

onKeyDownMethod · 0.90
onKeyUpMethod · 0.90
onKeyDownFunction · 0.90
onKeyUpFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected