default.js: handle canceled key bindings

This commit is contained in:
nanahi 2024-06-06 09:36:33 -04:00 committed by avih
parent eeb8e6e451
commit 31ae111ff5
1 changed files with 5 additions and 1 deletions

View File

@ -311,6 +311,7 @@ function add_binding(forced, key, name, fn, opts) {
fn({
event: KEY_STATES[state[0]] || "unknown",
is_mouse: state[1] == "m",
canceled: state[2] == "c",
key_name: key_name || undefined,
key_text: key_text || undefined
});
@ -321,7 +322,10 @@ function add_binding(forced, key, name, fn, opts) {
// Emulate the semantics at input.c: mouse emits on up, kb on down.
// Also, key repeat triggers the binding again.
var e = state[0],
emit = (state[1] == "m") ? (e == "u") : (e == "d");
emit = (state[1] == "m") ? (e == "u") : (e == "d"),
canceled = state[2] == "c";
if (canceled)
return;
if (emit || e == "p" || e == "r" && key_data.repeatable)
fn();
}