Selkies

lib/touch-controls

What the dashboard offers touch clients beside its soft modifier keys.

The special-key palette: the keys an on-screen keyboard lacks (function keys, arrows, the editing block), a few chords, and the user's own chords. A chord is text such as Ctrl+Shift+T; the dashboards play it as the synthetic KeyboardEvents their soft keys already dispatch, which the input handler forwards like real ones (chordEvents).

The trackpad speeds the dashboards offer, as factors on the input handler's accelerated trackpad travel (Input.setTrackpadSpeed).

Variables

TRACKPAD_SPEEDS

const TRACKPAD_SPEEDS: number[];

Defined in: lib/touch-controls.js:22

The trackpad speeds offered, 1 being the handler's own curve.


TRACKPAD_SPEED_KEY

const TRACKPAD_SPEED_KEY: "trackpad_speed" = 'trackpad_speed';

Defined in: lib/touch-controls.js:25

The storage key, under the dashboards' prefix, of the trackpad speed (the cores keep it).


PALETTE_KEYS

const PALETTE_KEYS: string[][];

Defined in: lib/touch-controls.js:28

The palette's one-shot keys, as [label, key, code].


PALETTE_CHORDS

const PALETTE_CHORDS: string[];

Defined in: lib/touch-controls.js:38

The chords every palette offers before the user's own.


USER_CHORDS_KEY

const USER_CHORDS_KEY: "user_chords" = 'user_chords';

Defined in: lib/touch-controls.js:41

The storage key, under the dashboards' prefix, of the user's own chords.


USER_CHORDS_MAX

const USER_CHORDS_MAX: 24 = 24;

Defined in: lib/touch-controls.js:44

Most user chords kept.

Functions

parseChord()

function parseChord(text): object;

Defined in: lib/touch-controls.js:95

Reads a chord written as modifiers and one key joined by +, in any case (ctrl+shift+t, Alt+F4, Win+D).

Parameters

ParameterTypeDescription
textstring-

Returns

object

Its modifiers and its key, each as [name, key, code], or null when it is not a chord: no key, a key that is not one, a modifier written twice, or a modifier alone.

mods
mods: string[][];
key
key: string[];

formatChord()

function formatChord(chord): string;

Defined in: lib/touch-controls.js:124

A chord written back the one way the palette shows and stores it.

Parameters

ParameterTypeDescription
chord{ mods: string[][]; key: string[]; }From parseChord.
chord.modsstring[][]-
chord.keystring[]-

Returns

string


chordEvents()

function chordEvents(chord, held?): object[];

Defined in: lib/touch-controls.js:139

The key events a chord is played as: its modifiers pressed in order, its key pressed and released, and its modifiers released in reverse. A modifier the user already holds on a soft key is left to it, neither pressed nor released, and every event carries the modifier state it leaves.

Parameters

ParameterTypeDescription
chord{ mods: string[][]; key: string[]; }From parseChord.
chord.modsstring[][]-
chord.keystring[]-
held?{ Control?: boolean; Alt?: boolean; Meta?: boolean; Shift?: boolean; }The soft keys held now.
held.Control?boolean-
held.Alt?boolean-
held.Meta?boolean-
held.Shift?boolean-

Returns

object[]


readUserChords()

function readUserChords(storage, storageKey): string[];

Defined in: lib/touch-controls.js:164

The user's own chords from storage, each still one (parseChord), written back as the palette writes them, without repeats.

Parameters

ParameterTypeDescription
storageStorage-
storageKeystringThe prefixed USER_CHORDS_KEY.

Returns

string[]


writeUserChords()

function writeUserChords(
   storage, 
   storageKey, 
   chords
): void;

Defined in: lib/touch-controls.js:188

Keeps the user's own chords in storage; a storage that refuses them (a private window, a full quota) leaves them for this page's life.

Parameters

ParameterTypeDescription
storageStorage-
storageKeystringThe prefixed USER_CHORDS_KEY.
chordsstring[]-

Returns

void