Can't use camelCase property name when defining and using Vue.config.keyCodes
Can't use camelCase property name when defining and using Vue.config.keyCodes
I am trying to set up keyCodes for a keyup
Using event v-on
from Vue.js.
I read the documentation and found Vue.config.keyCodes = {}
which is a static method. User can set custom names for keyCodes.
Problem 1: camelCase property name doesn't work.
below is a JSFiddle without camelCase and it works well.
Ref: no camelCase config
below is a JSFiddle with camelCase and it doesn't work.
Ref: with camelCase config
CamelCase example in Vue.js. I think camelCase should work too. why is it not working?
Problem 2: binding multiple keycodes
I want to contribute Alert
when typing cmd
+ enter
.
I've tried @keyup.91.13
, @keyup.91&&13
or the keyCode config like
Vue.config.keyCodes = {
hit: 91&&13
}
but that won't work. How can I make this work correctly?
source to share
Problem 1:
I believe only by design. I thought it .call-alert
might work, but it doesn't. I think modifiers are limited to all lowercase letters.
Problem 2:
Since command
- this is a modifier key you can do:
@keyup.ctrl.enter="dance"
You can find more details on this here: https://vuejs.org/v2/guide/events.html#Modifier-Keys
source to share
Problem 2: binding multiple keycodes
Better to use ".meta" because "keyup = 91" does not work for Opera (its "keyup = 219", not 91).
@keyup.meta.enter="yourMethod"
(But I don't know why this doesn't work for me on Ubuntu)
Note. On Macintosh keyboards, meta is the command key (⌘). On Windows keyboard, meta is the window key (⊞). On Sun Microsystems keyboards, meta is referred to as a hard diamond (◆). On some keyboards, notably MIT and Lisp machine keyboards and successors such as the Knight Keyboard, the space course keyboard, the meta is labeled "META". On the Symbolics keys, meta are referred to as "META" or "Meta".
source to share