1
mirror of https://github.com/mpv-player/mpv synced 2024-10-02 16:25:33 +02:00

manpage: lua: attempt to improve add_key_binding() description

This commit is contained in:
wm4 2014-02-17 20:25:11 +01:00
parent c79ea489bf
commit 6d87f6f550

View File

@ -141,24 +141,29 @@ The ``mp`` module is preloaded, although it can be loaded manually with
nothing if the ``name`` wasn't registered. nothing if the ``name`` wasn't registered.
``mp.add_key_binding(key, name|fn [,fn])`` ``mp.add_key_binding(key, name|fn [,fn])``
Register a key binding. The binding will be mapped to the given ``key``, Register callback to be run on a key binding. The binding will be mapped to
which is a string describing the physical key. This uses the same key the given ``key``, which is a string describing the physical key. This uses
names as in input.conf, and also allows combinations (e.g. ``ctrl+a``). the same key names as in input.conf, and also allows combinations
(e.g. ``ctrl+a``).
Key bindings are dispatched as script commands. The ``name`` argument is After calling this function, key presses will cause the function ``fn`` to
the name used to invoke command handlers as registered by be called (unless the user overmapped the key with another binding).
``mp.register_script_command``. The name can also be used by users to remap
the bindings provided by your script (see below).
If a key binding or a command with the given name already exists, it's The ``name`` argument should be a short symbolic string. It allows the user
overwritten. to remap the key binding via input.conf using the ``script_message``
command, the script name, and the name of the key binding (see below for
an example). The name should be unique across other bindings in the same
script - if not, the previous binding with the same name will be
overwritten. You can omit the name, in which case a random name is generated
internally.
The ``fn`` parameter is optional. If provided, it must be a function, and Internally, key bindings are dispatched via the ``script_message`` input
will be called when the key is pressed. Actually, this just for command and ``mp.register_script_command``.
convenience, and literally calls ``mp.register_script_command(name, fn)``.
You can also omit the name and only provide a function ``fn`` instead. Then Trying to map multiple commands to a key will essentially prefer a random
a random name is generated internally. binding, while the other bindings are not called. It is guaranteed that
user defined bindings in the central input.conf are preferred over bindings
added with this function (but see ``mp.add_forced_key_binding``).
Example: Example: