Charles
Charles

Reputation: 11778

EmberJS requiredKeys for action

How can I define an action (on click) which is only call when a specific modifier key is pressed?

allowedKeys also executes the action when no modifier keys are pressed.

Upvotes: 0

Views: 21

Answers (1)

Bek
Bek

Reputation: 3207

One approach will be just do

<div onclick={{action 'itemClick'}}> my item </div>  

and in your controller/parent component

actions: {
  itemClick(e){
    if (e.altKey) {
       // alt key 
    } else if (e.ctrlKey) {
       // ctrl key 
    }
  }
}

Upvotes: 1

Related Questions