From 14971424b981511423ddbe966c92719c45eeebb8 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Wed, 20 Nov 2019 16:23:54 +0200 Subject: [PATCH] js: report key name for "complex" key bindings - match b08c8f50 --- player/javascript/defaults.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/player/javascript/defaults.js b/player/javascript/defaults.js index c91228087d..1843945dae 100644 --- a/player/javascript/defaults.js +++ b/player/javascript/defaults.js @@ -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 [/]" 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 {