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

Method handleKeyChar

content_scripts/mode_key_handler.js:123–146  ·  view source on GitHub ↗
(keyChar)

Source from the content-addressed store, hash-verified

121 }
122
123 handleKeyChar(keyChar) {
124 // A count prefix applies only so long a keyChar is mapped in @keyState[0]; e.g. 7gj should be 1j.
125 if (!(keyChar in this.keyState[0])) {
126 this.countPrefix = 0;
127 }
128
129 // Advance the key state. The new key state is the current mappings of keyChar, plus @keyMapping.
130 const state = this.keyState.filter((mapping) => keyChar in mapping).map((mapping) =>
131 mapping[keyChar]
132 );
133 state.push(this.keyMapping);
134 this.keyState = state;
135
136 if (this.keyState[0].command != null) {
137 const command = this.keyState[0];
138 const count = this.countPrefix > 0 ? this.countPrefix : null;
139 this.reset();
140 this.commandHandler({ command, count });
141 if ((this.options.count != null) && (--this.options.count <= 0)) {
142 this.exit();
143 }
144 }
145 return this.suppressEvent;
146 }
147}
148
149globalThis.KeyHandlerMode = KeyHandlerMode;

Callers 1

onKeydownMethod · 0.95

Calls 5

resetMethod · 0.95
filterMethod · 0.45
pushMethod · 0.45
commandHandlerMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected