The key binding interface.

interface KeyBinding {
    fn?: ((dt: number) => void);
    id: string;
    key: string;
    name?: string;
    onDown?: (() => void);
    onDownContinuous?: ((dt: number) => void);
    onPress?: (() => void);
    onUp?: (() => void);
}

Properties

fn?: ((dt: number) => void)

Equivalent to onDownContinuous. Use either that or onDown, onPress, onUp instead.

id: string

The id of the key binding, for use when updating. Note: In versions before 8.2.0, name was used as the id.

key: string

The key associated with the binding.

name?: string

The name of the key binding. You can use this for display purposes. Note: In versions before 8.2.0, this was used as the id.

onDown?: (() => void)

The function executed when the binding is pressed down. Uses the default "keydown" event (which is called once when the key is pressed down, has a slight delay, and then repeats if held down for a while).

onDownContinuous?: ((dt: number) => void)

A function that is executed every frame while the binding is being pressed.

Type declaration

    • (dt): void
    • Parameters

      • dt: number

        The time since the last frame, in milliseconds.

      Returns void

onPress?: (() => void)

The function executed when the binding is being pressed.

onUp?: (() => void)

The function executed when the binding is released.