🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

keyboard-shortcut-string

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keyboard-shortcut-string

Creates a canonical keyboard shortcut string from a shortcut source string

latest
Source
npmnpm
Version
2.0.1
Version published
Maintainers
1
Created
Source

Keyboard Shortcut String

Creates a canonical keyboard shortcut string from the given shortcut string input.

This module does not bind shortcuts to keyboard events – its only job is to parse shortcut strings, and return predictable results. A good use for this module would be to support a keystroke module's event handler mapping.

Examples:

console.log(getCanonicalShortcut('ctrl s'));
// 'ctrl s'

console.log(getCanonicalShortcut('s ctrl'));
// 'ctrl s'

console.log(getCanonicalShortcut('s   ctrl'));
// 'ctrl s'

console.log(getCanonicalShortcut('shift ctrl s'));
// 'shift ctrl s'

console.log(getCanonicalShortcut('ctrl shift s'));
// 'shift ctrl s'

console.log(getCanonicalShortcut('S   CTRL   SHIFT'));
// 'shift ctrl s'

Modifier Keys

  • shift
  • ctrl
  • alt
  • meta

Modifier keys are extracted from the input and placed in a predictable order at the front of the result.

Non-modifier Keys

Only one non-modifier key component is allowed: "alt s" works, but "alt s h" will throw.

Non-modifier keys can be almost anything: "s", "S", "space", "ESC", and lowercase is always returned.

Thanks!

This source is heavily sourced from MooTools Keyboard.parse.

License

MIT

Keywords

keyboard

FAQs

Package last updated on 19 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts