MCPcopy Index your code
hub / github.com/KilledByAPixel/LittleJS / onKeyDown

Method onKeyDown

plugins/uiSystem.js:1110–1122  ·  view source on GitHub ↗

Key down event handler if this object is being edited * @param {KeyboardEvent} [e]

(e)

Source from the content-addressed store, hash-verified

1108 /** Key down event handler if this object is being edited
1109 * @param {KeyboardEvent} [e] */
1110 onKeyDown(e)
1111 {
1112 const code = e.code, key = e.key
1113 if (code === 'Backspace')
1114 this.text = this.text.slice(0, -1);
1115 else if (code === 'Enter' || code === 'Escape')
1116 this.stopEditing();
1117 else if (key.length === 1) // printable characters
1118 {
1119 if (!this.maxLength || this.text.length < this.maxLength)
1120 this.text += key;
1121 }
1122 }
1123
1124 update()
1125 {

Callers 1

constructorMethod · 0.80

Calls 1

stopEditingMethod · 0.95

Tested by

no test coverage detected