0

I want to fire a function for cmd + click. But it looks impossible at least for my keyboard.

My keyboard type:

Macbook Turkish Q

It seems like because of Macbook CMD key works depend on browser, How can I set new key codes for vue.js easily?

<div @click="foo($event)" ></div>

foo(e){
console.log(e.ctrlKey) // If I press CMD and Click to DIV result always FALSE
console.log(e.shiftKey) // If I press SHIFT and Click to DIV result TRUE (shift working but cmd is not working)
}
Erdi
  • 1,824
  • 3
  • 21
  • 31
  • 1
    See [this question](How does one capture a Mac's command key via JavaScript?) – Vanquished Wombat Oct 22 '18 at 17:53
  • 1
    How can I change key codes In a component of Vuex? – Erdi Oct 22 '18 at 17:55
  • 1
    just cheking `e.metaKey` now and it's working, thank you! In my case, does not matter If click cmd or shift, I just need that if click cmd + click it sjould fire the function so, `e.metaKey` solved my problem – Erdi Oct 22 '18 at 18:00
  • 1
    Possible duplicate of [How does one capture a Mac's command key via JavaScript?](https://stackoverflow.com/questions/3902635/how-does-one-capture-a-macs-command-key-via-javascript) ? No it't not, this one is specific to Vuex which I missed. – Vanquished Wombat Oct 22 '18 at 18:00
  • 1
    Why not post an answer for the next guy ? I'll upvote it if you do. – Vanquished Wombat Oct 22 '18 at 18:01

1 Answers1

2

If you check e.metaKey it works! it handles CMD now.

Thank you.

Erdi
  • 1,824
  • 3
  • 21
  • 31