Get all registered mpv (and iina) key bindings.
A dictionary of key bindings, where the key is the key code and the value is an object with the following properties:
// check if a key binding is already registered
const kc = input.normalizeKeyCode("Shift+Alt+X")
if (input.getAllKeyBindings()[kc]) {
// alert the user: the key binding is already registered
}
Listen to a key down event.
The key (or key combination) to listen to. It should be a valid mpv key code.
To remove the listener, pass null
to this parameter.
Whether to stop the event propagation.
If true
, the event will not be passed down to other handlers.
The data associated with the event.
The x coordinate of the current mouse cursor, relative to the player window.
The y coordinate of the current mouse cursor, relative to the player window.
Whether the event is a repeat event (by holding down the key).
Optional
priority: numberThe priority of the handler. Higher priority handlers are called first.
Listen to a key up event.
The key (or key combination) to listen to. It should be a valid mpv key code.
To remove the listener, pass null
to this parameter.
Whether to stop the event propagation.
If true
, the event will not be passed down to other handlers.
The data associated with the event.
The x coordinate of the current mouse cursor, relative to the player window.
The y coordinate of the current mouse cursor, relative to the player window.
Whether the event is a repeat event (by holding down the key).
Optional
priority: numberThe priority of the handler. Higher priority handlers are called first.
Listen to a mouse up event.
Note that if you return true
in the callback,
both the default single-click and double-click actions in IINA will stop working.
You are responsible for handling them on your own.
The mouse button. Should be one of input.MOUSE
, input.RIGHT_MOUSE
, and input.OTHER_MOUSE
.
To remove the listener, pass null
to this parameter.
Whether to stop the event propagation.
If true
, the event will not be passed down to other handlers.
The data associated with the event.
The x coordinate of the current mouse cursor, relative to the player window.
The y coordinate of the current mouse cursor, relative to the player window.
Optional
priority: numberThe priority of the handler. Higher priority handlers are called first.
Listen to a mouse down event.
The mouse button. Should be one of input.MOUSE
, input.RIGHT_MOUSE
, and input.OTHER_MOUSE
.
To remove the listener, pass null
to this parameter.
Whether to stop the event propagation.
If true
, the event will not be passed down to other handlers.
The data associated with the event.
The x coordinate of the current mouse cursor, relative to the player window.
The y coordinate of the current mouse cursor, relative to the player window.
Optional
priority: numberThe priority of the handler. Higher priority handlers are called first.
Listen to a mouse drag event. Works for the left mouse button only.
The sole purpose of this method is to allow the plugin to know when a drag event is initiated
while the mouse button is hold down. If the user started dragging,
the plugin should not perform any action to interfere with the default dragging behavior.
In short, if you need to do something while the mouse button is hold down,
listen to both mouseDown
and mouseDrag
events, and cancel your action when either of them fires.
The mouse button. Should always be input.MOUSE
.
To remove the listener, pass null
to this parameter.
Whether to stop the event propagation, but it has no effect.
Should always return false
.
Optional
priority: numberThe priority of the handler, however it has no effect.
There is no way to override the default dragging behavior in IINA.
Should always be PRIORITY_LOW
.
Generated using TypeDoc
The
Input
module provides methods to capture mouse and keybord events in the player window. Although it can be used to add keyboard shortcuts, it is recommended to use the Menu module to do so. This module, by providing both thekeyDown
/mouseDown
andkeyUp
/mouseUp
listeners, provides more user interaction possibilities; for example, you can implement a "hold to seek" feature.Each listener is associated with a priority. Listeners with higher priority are called first. If the priority
>= PRIORITY_HIGH
, the handler will be called before the default handlers, e.g. mpv key bindings. To be more specific, the listeners are called in the following order:>= PRIORITY_HIGH
< PRIORITY_HIGH
You should avoid using
PRIORITY_HIGH
unless necessary. The default priority is alwaysPRIORITY_LOW
.The event callback should return a boolean value indicating whether the event is handled. If the event is handled, it will not be passed down to other listeners (which might include the default handlers in IINA, therefore overriding the default behavior).
In IINA, an input event is sent to the menu bar first, then to the frontmost window. Therefore, under current implementation, if a key input is captured by one of the menu items, it will not be passed down to this module. We may change this behavior in the future, but for now, you should not expect much from the priority system and always use
PRIORIY_LOW
for your listeners.For mouse events, due to the complexity of the underlying implementation, currently it is not possible to detect drag events. For more advanced mouse event handling, the overlay module might be helpful.
Example
Hold the mouse button to speed up the playback:
Available In Entry
Main entry only