快捷键组合库
npm install @suporka/keybind
npm i @suporka/keybind --save
`
$3
`ts
import keybind from '@suporka/keybind'
// bind one
keybind.bind('ctrl + s', function(event) {
// do what you want to do
}, context)
// bind more
keybind.bind(['ctrl + s', 'shift + s'], function(event) {
event.preventDefault()
event.stopPropagation()
// do what you want to do
}, context)
// unbind all
keybind.unbind('ctrl + s')
// unbind one by callback
keybind.unbind('ctrl + s', callback, context)
`
$3
`ts
keybind.bind('ctrl + s', function(event) {
event.preventDefault()
event.stopPropagation()
// do what you want to do
}, context)
`
Supported keys
- modifiers shift, ctrl, alt
- letters a to z
- numbers 0 to 9
- functions f1 to f12
- arrows left, up, right, down
- ohter enter, esc, space, backspace, del, tab, pageup, pagedown, home, end, capslock, shift, ctrl, alt, ins
- shiftkey ~ ! @ # $ % ^ & * ( ) _ + : " < > ? |`