Hotkeys plugin

0.9 KB gzip
@tomato-player/plugin-hotkeys

Adds 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 — ts
import { 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

OptionTypeDescription
scope'focus' | 'global'Listen only while the player has focus, or on the whole page.
seekStepnumberArrow-key seek in seconds (default 5).
longSeekStepnumberJ and L seek in seconds (default 10).
volumeStepnumberVolume change per key press (default 0.1).
bindingsRecord<string, action | null>Add, replace or remove (null) bindings.

Other plugins

GesturesDouble-tap to seek on touch, with visual feedback.
ChaptersChapters from an array or WebVTT, with seek-bar markers.
ThumbnailsSeek-bar preview thumbnails from WebVTT sprite sheets.
PlaylistNext and previous, auto-advance and loop.
AnalyticsVendor-neutral QoE events: startup time, quartiles, rebuffering, watch time.
Media SessionLock-screen controls, artwork and hardware media keys.
PersistRemember volume, speed, captions and resume position.