Hotkeys plugin
0.9 KB gzipAdds keyboard shortcuts with familiar video-platform defaults: Space and K to play, J and L to jump 10 seconds, arrows to seek and change volume, Home and End, F for fullscreen, M to mute, C for captions and I for picture-in-picture. Every binding can be remapped or disabled.
Click the player, then press Space, J, L, the arrow keys, M, F or C.
Install
npm i @tomato-player/plugin-hotkeys
Usage
player.ts — tsimport { createPlayer } from '@tomato-player/core';import { minimal } from '@tomato-player/skin-minimal';import { hotkeys } from '@tomato-player/plugin-hotkeys';createPlayer('#player', {src: 'movie.mp4',skin: minimal(),plugins: [hotkeys({ scope: 'focus', seekStep: 5, bindings: { p: (player) => player.togglePip() } })],});
Options
| Option | Type | Description |
|---|---|---|
| scope | 'focus' | 'global' | Listen only while the player has focus, or on the whole page. |
| seekStep | number | Arrow-key seek in seconds (default 5). |
| longSeekStep | number | J and L seek in seconds (default 10). |
| volumeStep | number | Volume change per key press (default 0.1). |
| bindings | Record<string, action | null> | Add, replace or remove (null) bindings. |