Skip to main content

types

Interfaces

ModifierState

Defined in: types.ts:16

The modifier flags of a WheelEvent or a KeyboardEvent.

Properties

altKey
altKey: boolean;

Defined in: types.ts:18

ctrlKey
ctrlKey: boolean;

Defined in: types.ts:19

metaKey
metaKey: boolean;

Defined in: types.ts:20

shiftKey
shiftKey: boolean;

Defined in: types.ts:17


SelectedInputEvent

Defined in: types.ts:41

Properties

modifier
modifier: Modifier | null;

Defined in: types.ts:44

Which modifier entry was chosen, or null for default.

option
option: InputEventOption;

Defined in: types.ts:42

Type Aliases

InputEventOption

type InputEventOption = ["normalized" | "raw", number];

Defined in: types.ts:4

Options for setting the amount of keyboard and mouse wheel changes.


InputEventOptions

type InputEventOptions = ModifierValue<InputEventOption>;

Defined in: types.ts:39

How much one wheel notch or key press moves the value: a single amount, or one per modifier key.


Modifier

type Modifier = "shift" | "alt" | "ctrl" | "meta";

Defined in: types.ts:13

A modifier key that can carry an amount of its own.

ctrl and meta are kept apart rather than folded into one "command" key: a plugin UI that mirrors a desktop host usually wants the same physical key on every platform, not the platform's own convention.


ModifierMap

type ModifierMap<T> = object & Partial<Record<Modifier, T>>;

Defined in: types.ts:24

One setting per modifier key, with default for none of them.

Type Declaration

default
default: T;

Type Parameters

Type Parameter
T

ModifierValue

type ModifierValue<T> = T | ModifierMap<T>;

Defined in: types.ts:33

A single setting, or one per modifier key.

Type Parameters

Type Parameter
T

Example

['raw', 1]
{ default: ['raw', 1], shift: ['raw', 0.1] }

Functions

mapModifier()

function mapModifier<T, U>(options, fn): ModifierValue<U>;

Defined in: types.ts:116

Turn every entry of a setting into another kind of setting, keeping which modifier each belongs to.

A drag sensitivity is a number and a keyboard amount is a tuple, but the two describe the same thing from the caller's side. This carries one over to the other so that a component can hand a sensitivity to applyDelta without unpicking the modifier map itself — which matters, since naming a modifier is also what takes step out of the pipeline.

Type Parameters

Type Parameter
T
U

Parameters

ParameterType
optionsModifierValue<T>
fn(value) => U

Returns

ModifierValue<U>

Example

mapModifier({ default: 1, shift: 0.1 }, (f) => ['raw', step * f])
// { default: ['raw', 1], shift: ['raw', 0.1] }

selectInputEvent()

function selectInputEvent(options, modifiers?): SelectedInputEvent;

Defined in: types.ts:135

Pick the amount that applies, given the modifier keys being held.

Parameters

ParameterType
optionsInputEventOptions
modifiers?ModifierState

Returns

SelectedInputEvent

Example

selectInputEvent({ default: ['raw', 1], shift: ['raw', 0.1] }, event)

selectModifier()

function selectModifier<T>(options, modifiers?): object;

Defined in: types.ts:80

Pick the setting that applies, given the modifier keys being held.

Type Parameters

Type Parameter
T

Parameters

ParameterType
optionsModifierValue<T>
modifiers?ModifierState

Returns

object

modifier
modifier: Modifier | null;
value
value: T;

Example

selectModifier({ default: 1, shift: 0.1 }, event)