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

Function onKeyDown

app/static/js/app.js:110–160  ·  view source on GitHub ↗

* @param {KeyboardEvent} evt - https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent

(evt)

Source from the content-addressed store, hash-verified

108 * @param {KeyboardEvent} evt - https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
109 */
110function onKeyDown(evt) {
111 if (overlayTracker.hasOverlays()) {
112 return;
113 }
114
115 const canonicalCode = keystrokeToCanonicalCode(evt);
116
117 if (isIgnoredKeystroke(canonicalCode)) {
118 return;
119 }
120
121 keyboardState.onKeyDown(evt);
122
123 if (!connectedToServer) {
124 return;
125 }
126 if (!evt.metaKey) {
127 evt.preventDefault();
128 }
129
130 const onScreenKeyboard = document.getElementById("on-screen-keyboard");
131
132 processKeystroke({
133 metaLeft:
134 keyboardState.isKeyPressed("MetaLeft") ||
135 onScreenKeyboard.isModifierKeyPressed("MetaLeft"),
136 metaRight:
137 keyboardState.isKeyPressed("MetaRight") ||
138 onScreenKeyboard.isModifierKeyPressed("MetaRight"),
139 altLeft:
140 keyboardState.isKeyPressed("AltLeft") ||
141 onScreenKeyboard.isModifierKeyPressed("AltLeft"),
142 altRight:
143 keyboardState.isKeyPressed("AltRight") ||
144 onScreenKeyboard.isModifierKeyPressed("AltRight"),
145 shiftLeft:
146 keyboardState.isKeyPressed("ShiftLeft") ||
147 onScreenKeyboard.isModifierKeyPressed("ShiftLeft"),
148 shiftRight:
149 keyboardState.isKeyPressed("ShiftRight") ||
150 onScreenKeyboard.isModifierKeyPressed("ShiftRight"),
151 ctrlLeft:
152 keyboardState.isKeyPressed("ControlLeft") ||
153 onScreenKeyboard.isModifierKeyPressed("ControlLeft"),
154 ctrlRight:
155 keyboardState.isKeyPressed("ControlRight") ||
156 onScreenKeyboard.isModifierKeyPressed("ControlRight"),
157 key: evt.key,
158 code: canonicalCode,
159 });
160}
161
162function sendMouseEvent(
163 buttons,

Callers

nothing calls this directly

Calls 6

keystrokeToCanonicalCodeFunction · 0.90
isIgnoredKeystrokeFunction · 0.85
processKeystrokeFunction · 0.85
hasOverlaysMethod · 0.80
onKeyDownMethod · 0.80
isKeyPressedMethod · 0.80

Tested by

no test coverage detected