keyboard-symbol
v1.0.0
Published
Convert key names to symbols like ⌘, ⇧, ⌥ and many more. Supports common symbols for Mac and Windows keyboards.
Downloads
15
Readme
keyboard-symbol
Convert key names to symbols like ⌘, ⇧, ⌥ and many more. Supports common symbols for Mac and Windows keyboards.
Install
npm install keyboard-symbol
Usage
import keyboardSymbol from 'keyboard-symbol'
keyboardSymbol('meta', 'mac')
//=> ⌘
keyboardSymbol('meta', 'win')
//=> ❖
keyboardSymbol('control', 'mac')
//=> ⌃
keyboardSymbol('control', 'win')
//=> ctrl
keyboardSymbol('unknownKeyName', 'mac')
//=> unknownKeyName
API
keyboardSymbol(key, OS)
key
Type: string
Default: ''
Your KeyboardEvent.key.
OS
Type: string
Default: mac
Can be mac
or win
.
List of symbols
⌃ ⌥ ⌘ ❖ ⇪ ⇧ ↑ → ↓ ← ↩ ⌫ ⌦ ⎋ ⇥ ⇞ ⇟ ␣ ctrl alt (source)