mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-18 05:25:08 +00:00
Allow array of keycombos in useKeydown
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
export default {
|
||||
setup({closeModal}){
|
||||
useKeydown({key: 'Escape', fn: closeModal})
|
||||
useKeydown([{key: 'Escape', fn: closeModal}])
|
||||
},
|
||||
props: {
|
||||
closeModal: {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { onBeforeUnmount } from 'vue';
|
||||
|
||||
export const useKeydown = function(keyCombo) {
|
||||
export const useKeydown = function(keyCombos) {
|
||||
let onkey = function(event) {
|
||||
if(keyCombo.key == event.key) {
|
||||
keyCombo.fn()
|
||||
let kc = keyCombos.find(({key, fn}) => key == event.key )
|
||||
if(kc) {
|
||||
kc.fn()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user