MCPcopy Create free account
hub / github.com/melonjs/melonJS / keyDownEvent

Function keyDownEvent

packages/melonjs/src/input/keyboard.ts:28–48  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

26) => void;
27
28const keyDownEvent: KeyEventHandler = (options) => {
29 // eslint-disable-next-line @typescript-eslint/no-deprecated
30 const { keyCode } = options;
31 const action = _keyBindings[keyCode];
32
33 emit(KEYDOWN, action, keyCode, action ? !_keyLocked[action] : true);
34
35 if (action) {
36 if (!_keyLocked[action]) {
37 const trigger =
38 ("mouseButton" in options ? options.mouseButton : undefined) ?? keyCode;
39 if (!_keyRefs[action][trigger]) {
40 _keyStatus[action]++;
41 _keyRefs[action][trigger] = true;
42 }
43 }
44 if ("preventDefault" in options && _preventDefaultForKeys[keyCode]) {
45 options.preventDefault();
46 }
47 }
48};
49
50const keyUpEvent: KeyEventHandler = (options) => {
51 // eslint-disable-next-line @typescript-eslint/no-deprecated

Callers 1

initKeyboardEventFunction · 0.85

Calls 2

emitFunction · 0.90
preventDefaultMethod · 0.80

Tested by

no test coverage detected