Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "keyseq"

Index

Type aliases

KeyEventLike

KeyEventLike: MinimalKey | MsgSafeKeyboardEvent | KeyboardEvent

KeyModifiers

KeyModifiers: object

Key-sequence parser

Given an iterable of keys and a mapping of keys to objects, return:

  • parser(keyseq, map): the mapped object and a count OR a suffix of keys[] that, if more keys are pressed, could map to an object.
  • completions(keyseq, map): an array of keysequences in map that keyseq is a valid prefix of.

    No key sequence in map may be a prefix of another key sequence in map. This is a point of difference from Vim that removes any time-dependence in the parser.

Type declaration

  • Optional altKey?: boolean
  • Optional ctrlKey?: boolean
  • Optional metaKey?: boolean
  • Optional shiftKey?: boolean

Functions

bracketexprToKey

  • bracketexprToKey(be: string): [MinimalKey, string]
  • String starting with a bracket expr or a literal < to MinimalKey and remainder.

    Bracket expressions generally start with a < contain no angle brackets or whitespace and end with a >. These special-cased expressions are also permitted: <{optional modifier}<> or <{optional modifier}>>

    If the string passed does not match this definition, it is treated as a literal <.

    In sort of Backus Naur:

    • bracketexpr ::= '<' modifier? key '>'
    • modifier ::= 'm'|'s'|'a'|'c' '-'
    • key ::= '<'|'>'|/[^\s<>]+/

    Modifiers are case insensitive.

    The following case insensitive vim compatibility aliases are also defined:

    cr: 'Enter', return: 'Enter', space: 'Enter', bar: '|', del: 'Delete', bs: 'Backspace', lt: '<',

    Compatibility breaks:

    Shift + key must use the correct capitalisation of key: != J, == J.

    In Vim == on most systems. Not so here: we can't detect platform, so just have to use what the browser gives us.

    Vim has a predefined list of special key sequences, we don't: there are too many (and they're non-standard).1.

    In Vim, you're still allowed to use within angled brackets:

    == == > Here only the first two will work.

    Restrictions:

    It is not possible to map to a keyevent that actually sends the key value of any of the aliases or to any multi-character sequence containing a space or >. It is unlikely that browsers will ever do either of those things.

    Parameters

    • be: string

    Returns [MinimalKey, string]

hasModifiers

hasNonShiftModifiers

  • shiftKey is true for any capital letter, most numbers, etc. Generally care about other modifiers.

    Parameters

    Returns boolean

isSimpleKey

mapstrToKeyseq

Generated using TypeDoc