Options
All
  • Public
  • Public/Protected
  • All
Menu

Module keyboard

Index

Functions

isSimpleKeyCombo

  • isSimpleKeyCombo(event: KeyboardEvent, skc: SimpleKeyCombo): boolean

parseSimpleKeyCombo

  • Parse a human-readable string like "Ctrl+Shift+B" and turn it into a SimpleKeyCombo, asserting if it fails. Use tryParseSimpleKeyCombo instead if you're parsing user input, which will return undefined if it fails. The behavior of any unspecified keys on matching the combination is controlled by modifierDefaults. modifierDefaults defaults to all false, which means e.g. "Ctrl+Shift+B" won't match Ctrl+Alt+Shift+B.

    Additionally, you can use ? to ignore a modifier (e.g. "?Ctrl+Shift+B" will ignore if Ctrl is held or not), or use ! to specify a modifier cannot be held (e.g. "!Ctrl+Shift+B" demands Ctrl is not held, ignoring modifierDefaults.ctrl)

    Parameters

    • desc: string
    • Default value modifierDefaults: SimpleKeyModifiers = { alt: false, shift: false, ctrl: false, meta: false }

    Returns SimpleKeyCombo

systemConflictsWithSimpleKeyCombo

  • Return a list of any browser/system/global keybindings which might conflict with your simple key combination, along with information about the keys, origin, and action that your combo conflicts with. Some examples:

    { keys: "Ctrl+Shift+B",      origin: "Browser", action: "Toggle bookmarks bar" }
    { keys: "F1",                origin: "Browser", action: "Help"                 }
    { keys: "Ctrl+Shift+Esc",    origin: "System",  action: "Task manager"         }
    { keys: "Ctrl+Alt+Up",       origin: "Media",   action: "Player volume up"     }
    { keys: "Alt+PageDown",      origin: "f.lux",   action: "Dim"                  }

    Some bindings will be fine to override (you may not have f.lux installed at all), others can't possibly be overridden at all (Ctrl+Alt+Del).

    Parameters

    • skc: SimpleKeyCombo

      Your simple key combination that might conflict with system keybindings.

    Returns ReservationEntry[]

tryParseSimpleKeyCombo

  • Parse a human-readable string like "Ctrl+Shift+B" and turn it into a SimpleKeyCombo, or returns undefined. Use parseSimpleKeyCombo instead if you're parsing hardcoded strings, which will assert if it fails. The behavior of any unspecified keys on matching the combination is controlled by modifierDefaults. modifierDefaults defaults to all false, which means e.g. "Ctrl+Shift+B" won't match Ctrl+Alt+Shift+B.

    Additionally, you can use ? to ignore a modifier (e.g. "?Ctrl+Shift+B" will ignore if Ctrl is held or not), or use ! to specify a modifier cannot be held (e.g. "!Ctrl+Shift+B" demands Ctrl is not held, ignoring modifierDefaults.ctrl)

    Parameters

    • description: string
    • Default value modifierDefaults: SimpleKeyModifiers = { alt: false, shift: false, ctrl: false, meta: false }

    Returns SimpleKeyCombo | undefined

Generated using TypeDoc