kborad
v0.0.1
Published
quickly addEventListener for keyboard events
Downloads
2
Readme
keyboard
Description
quickly bind multiple-key keyboard event
Demo
keyboard()
.ctrl()
.letter('s')
.listen(() => {
console.log(`saving...`)
})
Option
maxTime
specific listener call max time
keyboard({ maxTime: 5 })
.ctrl()
.letter('s')
.listen(() => {
console.log(`saving...`)
})
preventDefault
whether to preventDefault with keydown
and keyup
event(on document
)
keyboard({ preventDefault: true })
.ctrl()
.letter('f')
.listen(() => {
console.log(`searching...`)
})
Api
letter
keyboard()
.letter('a')
.letter('b')
.listen(() => {
console.log('you press a + b...')
})
ctrl
.alt(), .command(), .shift() as same
import { Position } from 'keyboard'
keyboard()
.ctrl(Position.left)
.letter('a')
.listen(() => {
console.log('you press left ctrl + a...')
})
keyboard()
.ctrl(Position.right)
.letter('a')
.listen(() => {
console.log('you press right ctrl + a...')
})
keyboard()
.ctrl()
.letter('a')
.listen(() => {
console.log('you press left or right ctrl + a...')
})
getCallTime
keyboard()
.letter('a')
.letter('b')
.listen((e) => {
console.log(`you press a + b ${e.getCallTime()} times...`)
})