Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions web/src/lib/shortcuts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe('tvKeyOf', () => {

it('maps the keys', () => {
expect(tv(' ')).toBe('playPause')
expect(tv('MediaPlayPause')).toBe('playPause')
expect(tv('ArrowRight')).toBe('skip')
expect(tv('ArrowUp')).toBe('previousLook')
expect(tv('ArrowDown')).toBe('nextLook')
Expand All @@ -85,6 +86,7 @@ describe('tvKeyOf', () => {
it('stays out of combos, held skips, and typing', () => {
expect(tv('ArrowRight', { repeat: true })).toBeUndefined()
expect(tv('ArrowDown', { repeat: true })).toBe('nextLook')
expect(tv('MediaPlayPause', { repeat: true })).toBeUndefined()
expect(tv('ArrowRight', { altKey: true })).toBeUndefined()
expect(tv('ArrowDown', { target: el('<input>') })).toBeUndefined()
expect(tv('k', { target: el('<input>') })).toBeUndefined()
Expand Down
4 changes: 3 additions & 1 deletion web/src/lib/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export type TvKey = 'playPause' | 'skip' | 'nextLook' | 'previousLook' | 'visual
* The big screen's keys: space (or K, even on a button) plays and pauses, → skips (or votes to),
* ↑ and ↓ change the visuals, V turns them off and on. A remote's D-pad sends arrows too, so → is
* left to move between buttons while one has focus; nothing sits above or
* below them, so ↑ and ↓ are always free.
* below them, so ↑ and ↓ are always free. A Syncphony box's TV remote
* (HDMI-CEC) sends Enter, arrows, Escape and the media key for play/pause.
*/
export function tvKeyOf(e: Key): TvKey | undefined {
if (e.defaultPrevented || isTyping(e.target) || e.metaKey || e.ctrlKey || e.altKey) return undefined
Expand All @@ -76,6 +77,7 @@ export function tvKeyOf(e: Key): TvKey | undefined {
return e.repeat || onControl ? undefined : 'playPause'
case 'k':
case 'K':
case 'MediaPlayPause':
return e.repeat ? undefined : 'playPause'
case 'ArrowRight':
return e.repeat || onControl ? undefined : 'skip'
Expand Down
Loading