js: report key name for "complex" key bindings - match b08c8f50

This commit is contained in:
Avi Halachmi (:avih) 2019-11-20 16:23:54 +02:00 committed by avih
parent da13a3b231
commit 14971424b9
1 changed files with 5 additions and 4 deletions

View File

@ -177,10 +177,10 @@ mp.abort_async_command = function abort_async_command(id) {
// {cb: fn, forced: bool, maybe input: str, repeatable: bool, complex: bool}
var binds = new_cache();
function dispatch_key_binding(name, state) {
function dispatch_key_binding(name, state, key_name) {
var cb = binds[name] ? binds[name].cb : false;
if (cb) // "script-binding [<script_name>/]<name>" command was invoked
cb(state);
cb(state, key_name);
}
function update_input_sections() {
@ -217,10 +217,11 @@ function add_binding(forced, key, name, fn, opts) {
fn({event: "press", is_mouse: false});
});
var KEY_STATES = { u: "up", d: "down", r: "repeat", p: "press" };
key_data.cb = function key_cb(state) {
key_data.cb = function key_cb(state, key_name) {
fn({
event: KEY_STATES[state[0]] || "unknown",
is_mouse: state[1] == "m"
is_mouse: state[1] == "m",
key: key_name || undefined
});
}
} else {