From 0af0c137bb7452b67097fb138dca997324f44555 Mon Sep 17 00:00:00 2001 From: CogentRedTester Date: Wed, 18 Feb 2026 18:36:18 +1030 Subject: [PATCH] console.lua: flush keybinds before sending mp.input `opened` events This commit uses the undocumented `mp.flush_keybindings()` method to ensure that all `console.lua` keybinds are set before sending the `opened` event to `mp.input` clients. Previously, the keybinds would only be flushed when `console.lua` went idle. As the `opened` event is sent before this happens, clients processing the event may end up flushing their own keybinds before this happens. This makes it unreliable to use the `opened` event to override keybinds set by `console.lua`; for example, adding different behaviour to `input.select` when using `Shift+Enter` instead of `Enter`. This commit allows the `opened` callback to be used to safely override `console.lua` keybinds. .luacheckrc: move flush_keybindings to globals --- .luacheckrc | 2 +- player/lua/console.lua | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.luacheckrc b/.luacheckrc index dda48b031d..d096c1c368 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -57,6 +57,7 @@ local mp_globals = { disable_key_bindings = {}, enable_key_bindings = {}, find_config_file = {}, + flush_keybindings = {}, format_time = {}, get_mouse_pos = {}, set_key_bindings = {}, @@ -78,7 +79,6 @@ local mp_internal = { UNKNOWN_TYPE = { fields = { info = {}, type = {} }}, _legacy_overlay = { fields = { res_x = {}, res_y = {}, data = {}, update = {} }}, cancel_timer = {}, - flush_keybindings = {}, get_osd_margins = {}, input_define_section = {}, input_disable_section = {}, diff --git a/player/lua/console.lua b/player/lua/console.lua index 5024c86479..0df5a7fe3f 100644 --- a/player/lua/console.lua +++ b/player/lua/console.lua @@ -1730,6 +1730,10 @@ mp.register_script_message("get-input", function (args) end set_active(true) + + -- We want to ensure the keybindings have been set before sending the "opened" event + -- in case scripts want to override our bindings. + mp.flush_keybindings() mp.commandv("script-message-to", input_caller, input_caller_handler, "opened") end)