Skip to main content

Module grammar

Module grammar 

Source
Expand description

The chord grammar, shared by str::parse at run time and the chord! macro at compile time.

A chord is terms joined by +, with optional whitespace around each: any number of modifiers, then exactly one key.

  • Modifiers: Shift, Ctrl or Control, Alt or Option, Meta, Super, Logo or Command, and ControlOrMeta.
  • A named key such as Enter, ArrowLeft or F5, or Key(Shift) for a key whose name is also a modifier.
  • A physical key, Code(KeyK).
  • A single letter or digit, such as K or 1, meaning that character.
  • A quoted character such as "é", with Rust’s escapes (\", \\, \n, \u{..}).
  • Plus for the + key.

Errors carry a byte range into the input, so a macro can point at the offending token.

Structs§

ChordError
A chord or keystroke that does not parse, with the byte range of the offending input.

Enums§

ChordErrorKind
The ways a chord can fail to parse.

Constants§

MODIFIER_NAMES
Every modifier name the grammar accepts, aliases included.

Functions§

bare_key_names
The named keys that can be written bare, which is every one whose name is not also a modifier. The rest are written Key(..).
modifier_named
The modifier with this name, aliases included.
parse_chord
Parses a chord such as Control+Shift+K.
parse_keystroke
Parses one key with no modifiers, such as K, Enter or Key(Shift).