Skip to content

Keys on the web ​

Remote keys become real keyboard events: trusted keydown/keyup (and keypress for keys that produce text) sent through the Chrome DevTools Protocol, the same path as physical input. The app's own key handling runs unchanged; toets never calls app code to "press" a key.

Default map ​

key follows W3C UI Events. keyCode follows the OIPF/HbbTV codes shared by Tizen, webOS and HbbTV browsers, except BACK.

toets keykeykeyCode
UP / DOWN / LEFT / RIGHTArrowUp ...38 / 40 / 37 / 39
SELECTEnter13
BACKEscape27
INFOInfo457
PLAY_PAUSEMediaPlayPause402
PLAY / PAUSE / STOPMediaPlay / MediaPause / MediaStop415 / 19 / 413
FAST_FORWARD / REWINDMediaFastForward / MediaRewind417 / 412
NEXT / PREVIOUSMediaTrackNext / MediaTrackPrevious425 / 424
RED / GREEN / YELLOW / BLUEColorF0Red ... ColorF3Blue403 - 406
CHANNEL_UP / CHANNEL_DOWNChannelUp / ChannelDown427 / 428
DIGIT_0 - DIGIT_90 - 948 - 57
HOME, MENUunmapped-

HOME and MENU are unmapped because TV operating systems keep them for themselves; web apps never receive them.

Overrides ​

Map what your app listens to. A spec replaces the default; null removes the key and, with it, the capability (tests requiring it are skipped):

ts
import { platforms } from '@toets/test';

// A Tizen build that reads keyCodes:
platforms.web({
  keys: {
    BACK: { key: 'XF86Back', keyCode: 10009 },
    PLAY_PAUSE: { key: 'MediaPlayPause', keyCode: 10252 },
    CHANNEL_UP: null,
  },
});

A spec is { key, code?, keyCode?, text? }. text makes the key produce characters (keypress, form input): SELECT uses '\r' so Enter activates buttons.

Trap: key must be a standard UI Events value or one character. Chromium delivers anything else (like XF86Back) as an empty key; the keyCode still arrives verbatim, which is what such builds read.

Long press ​

press(key, { holdMs }) sends keydown, then auto-repeat keydowns (event.repeat === true) after keyRepeat.delayMs every keyRepeat.intervalMs, then keyup at holdMs. Match keyRepeat to the target device if your app counts repeats.