-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keybindings work only with a specific locale #11758
Comments
disagree, having y be z for me would be insanely confusing |
I'm not aware of any application that works like this (at least not by default). Closest thing I can recall is the dwm-keycode patch that modifies dwm to use X11 keycodes instead of keysyms. |
Well, mpv is designed to invoke the command which is bound to the text which the key produces. If you change locale and as a result a key produces different text, then it will no longer invoke the command which is bound to the previous text it produced. That is by design, and is unlikely to change. See https://mpv.io/manual/master/#key-names Note that some names are symbolic and should work in any locale, like So you have few options:
|
Cannot say about *nix soft, but in Windows hotkeys are locale independent. @avih |
Old and busy related issue (most interesting discussion happens around the 2016 time frame imo): #351 |
For completeness and future reference, here's such a lua script which can map a key (maybe with some modifiers) to another key (with the same modifiers). It includes an example mapping of the keypad ( Save it as -- mpv key mapper by avih. see https://github.com/mpv-player/mpv/issues/11758
-- known issue: auto-repeat might not work for mapped keys at the mpv window,
-- but may work at the terminal. --native-keyrepeat might help. see note below.
-- add (or remove) as many mapping as needed at keymap below, but note
-- that this only works for unmapped key events, i.e. when mpv decides
-- that some key (maybe with modifiers) is not bound, then this map kicks in
-- keymap is a list of: ["<SOURCE-KEY>"] = "<TARGET-KEY>"
-- e.g. ["KP1"] = "END" so that all KP1 key events (with or without
-- modifiers) will translate to END key events with the same modifiers.
local keymap = {
-- example: map keypad keys to normal editing keys
["KP1"] = "END",
["KP2"] = "DOWN",
["KP3"] = "PGDWN",
["KP4"] = "LEFT",
-- KP5 doesn't seem to have an editing function?
["KP6"] = "RIGHT",
["KP7"] = "HOME",
["KP8"] = "UP",
["KP9"] = "PGUP",
-- maybe add a map of key text in some locale to english keys
}
local msg = require("mp.msg")
-- splits an mpv key name to modifiers (possibly empty string) and key.
-- the original key name is always a concatenation of these two parts.
local function key_split(keyname)
if keyname:find("%+.+") then
return keyname:match("(.*%+)(.+)")
end
return "", keyname
end
local key_ev_to_cmd = {
down = "keydown",
up = "keyup",
press = "keypress",
["repeat"] = "keypress",
}
mp.add_key_binding("UNMAPPED", function(t)
if t.key_name:find("MOUSE", 1, true) then
return -- we don't map mouse commands
end
local cmd = key_ev_to_cmd[t.event]
local modifiers, key = key_split(t.key_name)
local newkey = keymap[key]
if not cmd then
msg.error("No key event map for", t.event)
elseif newkey == key then
msg.error("error: key '".. key .. "' is mapped to itself")
elseif not newkey then
if cmd ~= "keyup" then -- message only on keydown/press
msg.warn("No binding or map found for key '" .. t.key_name .. "'")
end
else
msg.verbose(cmd, t.key_name, "->", modifiers .. newkey)
mp.commandv(cmd, modifiers .. newkey)
end
end, {complex=true})
-- note about autorepeat
--
-- we map repeat, but it doesn't always work where it matters.
-- if we don't generate any key event in response to a "repeat" event then
-- it will keep repeating, but if we generate a (mapped) key event for some
-- other key, then mpv automatically first cancels any currently-pressed key,
-- hence it will abort the autorepeat of the original key (and we won't get
-- a keyup event either).
--
-- one could think that using --native-keyrepeat to utilize the OS
-- autorepeat functionality could work around this, but at least
-- on Windows it doesn't seem to work, i.e. autorepeat still doesn't work
-- for mapped keys. it might work on other platforms though, so try it out.
--
-- However, while the above is true for the mpv window (where the VO and
-- mpv itself handle low-level key events - down, up, repeat), key events
-- at the terminal are handled by the terminal. In this case key-repeat
-- will send repeated key presses to mpv, and so autorepeat may work also
-- for mapped keys if pressed at the terminal window. |
Important Information
mpv version: 0.35.0-407-g959ef843
Windows 10 Pro 22H2 19045.2965
Source of the mpv binary: https://sourceforge.net/projects/mpv-player-windows/?path=/64bit
Reproduction steps
Expected behavior
Keybindings should work with any locale.
Hotkey should be bound to the physical key on the keyboard, not to the character generated by pressing the key.
Actual behavior
Keybindings work only when using the same locale as the specified characters in the input.conf
Log file
output.txt
The text was updated successfully, but these errors were encountered: