pinafore/src/routes/_components/shortcut/Shortcut.html
2019-08-19 20:23:58 -07:00

27 lines
632 B
HTML

<script>
import {
addToShortcutScope,
removeFromShortcutScope
} from '../../_utils/shortcuts'
export default {
data: () => ({ scope: 'global', key: null }),
oncreate () {
const { scope, key } = this.get()
addToShortcutScope(scope, key, this)
},
ondestroy () {
const { 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>