MCPcopy
hub / github.com/philc/vimium / onKeydown

Method onKeydown

content_scripts/mode_key_handler.js:60–85  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

58 }
59
60 onKeydown(event) {
61 const keyChar = KeyboardUtils.getKeyCharString(event);
62 const isEscape = KeyboardUtils.isEscape(event);
63 if (isEscape && ((this.countPrefix !== 0) || (this.keyState.length !== 1))) {
64 return DomUtils.consumeKeyup(event, () => this.reset());
65 } else if (isEscape && HelpDialog && HelpDialog.isShowing()) {
66 // If the help dialog loses the focus, then Escape should hide it; see point 2 in #2045.
67 HelpDialog.toggle();
68 return this.suppressEvent;
69 } else if (isEscape) {
70 // Some links stay "open" after clicking, until you mouse off of them, like Wikipedia's link
71 // preview popups. If the user types escape, issue a mouseout event here. See #3073.
72 HintCoordinator.mouseOutOfLastClickedElement();
73 return this.continueBubbling;
74 } else if (this.isMappedKey(keyChar)) {
75 this.handleKeyChar(keyChar);
76 return this.suppressEvent;
77 } else if (this.isCountKey(keyChar)) {
78 const digit = parseInt(keyChar);
79 this.reset(this.keyState.length === 1 ? (this.countPrefix * 10) + digit : digit);
80 return this.suppressEvent;
81 } else {
82 if (keyChar) this.reset();
83 return this.continueBubbling;
84 }
85 }
86
87 // This tests whether there is a mapping of keyChar in the current key state (and accounts for
88 // pass keys).

Callers

nothing calls this directly

Calls 4

resetMethod · 0.95
isMappedKeyMethod · 0.95
handleKeyCharMethod · 0.95
isCountKeyMethod · 0.95

Tested by

no test coverage detected