pinafore/src/routes/_components/shortcut/Shortcut.html

26 lines
620 B
HTML

<script>
import {
addToShortcutScope,
removeFromShortcutScope } from '../../_utils/shortcuts'
export default {
data: () => ({ scope: 'global', key: null }),
oncreate () {
let { scope, key } = this.get()
addToShortcutScope(scope, key, this)
},
ondestroy () {
let { scope, key } = this.get()
removeFromShortcutScope(scope, key, this)
},
methods: {
onKeyDown (event) {
event.stopPropagation()
event.preventDefault()
this.fire('pressed', {
key: event.key,
timeStamp: event.timeStamp })
}
}
}
</script>