quickly bind multiple-key keyboard event
keyboard()
.ctrl()
.letter('s')
.listen(() => {
console.log(`saving...`)
})
specific listener call max time
keyboard({ maxTime: 5 })
.ctrl()
.letter('s')
.listen(() => {
console.log(`saving...`)
})
whether to preventDefault with keydown
and keyup
event(on document
)
keyboard({ preventDefault: true })
.ctrl()
.letter('f')
.listen(() => {
console.log(`searching...`)
})
keyboard()
.letter('a')
.letter('b')
.listen(() => {
console.log('you press a + b...')
})
.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...')
})
keyboard()
.letter('a')
.letter('b')
.listen((e) => {
console.log(`you press a + b ${e.getCallTime()} times...`)
})