10 examples of 'addeventlistener keypress' in JavaScript

Every line of 'addeventlistener keypress' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
146keyPressListener(event) {
147 if (event.ctrlKey && event.keyCode === 70) {
148 this.inPageSearch.openSearchWindow();
149 }
150}
387keyPress(key: string): void {
388 const keydownEvent: any = document.createEvent('CustomEvent');
389 keydownEvent.key = key;
390 keydownEvent.ctrlKey = false;
391 keydownEvent.metaKey = false;
392 keydownEvent.initEvent('keydown', true, true);
393 this.target.editor.root.dispatchEvent(keydownEvent);
394
395 const keyupEvent: any = document.createEvent('CustomEvent');
396 keyupEvent.key = key;
397 keyupEvent.ctrlKey = false;
398 keyupEvent.metaKey = false;
399 keyupEvent.initEvent('keyup', true, true);
400 this.target.editor.root.dispatchEvent(keyupEvent);
401}
397function keypress( event ) {
398
399 key = event.keyCode;
400 val = event.type == 'keyup';
401 keys[ key ] = keys[ keyName( key ) ] = !val;
402
403 trigger( context[ event.type ], event );
404}
59export function keyDownOn(target, keyCode, modifiers, key) {
60 keyEventOn(target, 'keydown', keyCode, modifiers, key);
61}
14function keypress(event)
15{
16 iowrapper.send(String.fromCharCode(event.which), parseResponse);
17}
89window.addEventListener("keyup", function keydown(e) {
90 var keycode = e.which || window.event.keycode;
91 game.keyUp(keycode);
92});
55_removeKeyPressEvent() {
56 if (document.removeEventListener) { // DOMレベル2イベントモデル
57 document.removeEventListener("mousemove", this._keyPress.onKeyPressKeyDown, true);
58 document.removeEventListener("mouseup", this._keyPress.onKeyPressKeyUp, true);
59 document.removeEventListener("blur", this._keyPress.onKeyPressBlur, true);
60 }
61}
39_addEventListeners() {
40 for (const type of KEYBOARD_EVENTS) {
41 window.addEventListener(type, this._onKeyboardEvent, true);
42 }
43}
81AddListeners(): void {
82
83 window.addEventListener('keydown', (key) => {
84 this.OnKeyDown(key);
85 });
86 window.addEventListener('keyup', (key) => {
87 this.OnKeyUp(key);
88 });
89}
408function keypress(e: KeyboardEvent) {
409 if (app.active) {
410 app.keyPress(e);
411 }
412 }

Related snippets