ziko
Version:
A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...
25 lines (21 loc) • 644 B
JavaScript
const CATEGORY = 'key'
export const KeyListeners = {
onKeyDown(callback){
return this.on(
'keydown', callback,
{ category : CATEGORY, details_setter : ctx=> { ctx.kd = ctx.event.key }
})
},
onKeyPress(callback){
return this.on(
'keypress', callback,
{ category : CATEGORY, details_setter : ctx=> { ctx.kp = ctx.event.key }
})
},
onKeyUp(callback){
return this.on(
'keydown', callback,
{ category : CATEGORY, details_setter : ctx=> { ctx.ku = ctx.event.key }
})
},
}