Keyboard
Everything a pointer does, the keyboard does too. The wave's keys work while it has focus, the player's own anywhere in it, and none takes a key held with Ctrl, Alt or ⌘, which belong to the browser and the page.
The wave
The keys of the WAI-ARIA slider pattern:
-
← → ↑
↓ step by
stepSeconds(5 seconds) -
Page Up Page Down step by
largeStepRatio(a tenth of the sound) - Home End go to the start and the end
Press Tab until the wave above is focused, and try the keys on this page.
The player
With keys: true, the ready-made player
answers its own keys with the focus anywhere in it. Off
by default.
- Space plays and pauses
- M mutes and unmutes (a silent sound comes back at half)
-
← → go back and forward
seconds(5) -
↑ ↓ turn the volume up and
down by
volumeStep(5 %) -
> < go up and down the
look's
speeds, in order -
N goes to the next track,
Shift + N to the one before;
only for a player given
tracks(a playlist)
The control with the focus keeps the keys it uses: on
the wave the arrows are the slider's, and
M goes to the next marker when the page has
markers; on a button, Space presses the
button. Nothing happens while someone types in a field,
nor in your own part of the player (slot).
A held Space or M acts once.
createPlayer({
container,
src,
keys: {
scope: 'page', // also while nothing on the page has the focus
play: [' ', 'k'], // Space or K
mute: false, // no mute key
seconds: 10,
},
a11y: { keys: { announce: true } }, // "Volume 55%", "Playback speed 1.5×"
});
Each key is one name or several, as
KeyboardEvent.key writes them (' ', 'm', 'ArrowUp'), or
false to turn it off: play,
mute, back,
forward, volumeUp,
volumeDown, faster and
slower. A letter works whatever its case.
track is one letter ('n') or
false: the letter goes forward, and with
Shift back, as for the chapters. At an end of
the list, or held down, it does nothing, and a key you
gave another action keeps it. With
scope: 'page', the keys also reach the
player that played last (the first one, before any
played) while nothing on the page has the focus; a focus
in another player is that player's.
Zoom
With zoom: { keys: true }:
- + (or =) zooms in, - zooms out, 0 shows the whole sound
-
A key seek outside the view brings the view to it
(
revealKeys, on by default)
keys: { in: 'i', out: 'o', reset: false }
picks other keys or turns one off.
Markers
- M goes to the next marker, Shift + M to the previous one, and they say "No more markers" when there is none that way
-
Within
keys.backGraceseconds after a marker (1), Shift + M goes to the one before it, like a player's "previous track"
keys: { letter: 'k' } picks another letter,
keys: false turns them off.
Chapters
- C goes to the next chapter, Shift + C to the previous one, and they say where ("Chapter 2 of 4: The meeting, 0:02")
-
Within
keys.backGraceseconds after a chapter's start (1), Shift + C goes to the one before it
keys: { letter: 'k' } picks another letter,
keys: false turns them off.
Regions
- R and Shift + R select the next and previous region
- Enter plays it, L loops it, Delete removes it
- [ ] move its start, { } move its end
- Escape stops it and lets it go
keys: { select, loop, play, nudge, remove, release
}
sets each one: select and
loop take your own letter or
false, the others false to
turn them off. keys: false turns them all
off.
The wave in words
With description: { keys: true }:
- D says the description again
- P and Shift + P go to the next and previous part of sound, and say where ("Part 2 of 3, 24 seconds")
- Escape stops the browser's voice while it reads
The minimap and the volume
Both are sliders too. The minimap (with
a11y.minimap.keys): arrows move a quarter
of the view, Page Up and Page Down a whole view, Home
and End go to the ends. The volume bar: arrows by
step (5 %), Page Up and Page Down by a
tenth, Home and End to silent and full.
Caps Lock changes nothing
The direction comes from Shift, never from the letter's case, so M, C, R and P work the same with Caps Lock on.