Header menu logo issie

KeyBindings Module

Turns a key press into an action, using the table in KeyTypes and the context the user is in. This is the only place in Issie that should listen for keys. It replaces five mechanisms that grew independently and never agreed with each other: the Electron menu accelerators, the document.onkeydown reassigned on every render in SheetDisplay, the addEventListener subscription in Renderer, the one React handler in SelectedComponentView, and the arrow-key intercept in Update. KeyTypes says what the shortcuts are; this module says what they do and delivers them.

Types

Type Description

Resolution

One resolution, for the shadow log.

Functions and values

Function or value Description

actionOf id dispatch

Full Usage: actionOf id dispatch

Parameters:
id : ShortcutId
dispatch : Msg -> unit

chordOf ev

Full Usage: chordOf ev

Parameters:
Returns: Chord
ev : KeyboardEvent
Returns: Chord

contextOfModel m

Full Usage: contextOfModel m

Parameters:
Returns: KeyContext

Which context the model puts the user in, ignoring DOM focus (which is read separately, at key time, because it changes without the model changing). First match wins, so the order is the priority order.

m : Model
Returns: KeyContext

currentContext ()

Full Usage: currentContext ()

Parameters:
    () : unit

Returns: KeyContext

The context a key press should be resolved in.

() : unit
Returns: KeyContext

isMac

Full Usage: isMac

Returns: bool
Returns: bool

keyNameOf ev

Full Usage: keyNameOf ev

Parameters:
Returns: KeyName

Resolve a key event to a KeyName. ev.key alone will not do: on macOS Option rewrites it, so Cmd+Option+A arrives as "a" with a ring over it. ev.code alone will not do either, being physical and so wrong on any layout that is not QWERTY - Ctrl+A on AZERTY is physically KeyQ. So use ev.key wherever it is meaningful and fall back to the physical key only where it is not.

ev : KeyboardEvent
Returns: KeyName

modsOf ev

Full Usage: modsOf ev

Parameters:
Returns: Mods
ev : KeyboardEvent
Returns: Mods

onKeyDown dispatch e

Full Usage: onKeyDown dispatch e

Parameters:

The one key handler in Issie.

dispatch : Msg -> unit
e : Event

onKeyUp dispatch e

Full Usage: onKeyUp dispatch e

Parameters:
dispatch : Msg -> unit
e : Event

onWindowBlur dispatch arg2

Full Usage: onWindowBlur dispatch arg2

Parameters:

Ctrl released while the window is not focused produces no keyup at all.

dispatch : Msg -> unit
arg1 : Event

publishKeyLog ()

Full Usage: publishKeyLog ()

Parameters:
    () : unit

Expose the shadow log to the outside, next to window.issie. Debug builds only.

() : unit

setContextFromModel m

Full Usage: setContextFromModel m

Parameters:
m : Model

Type something to start searching.