27 lines
632 B
HTML
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>
|