ember-native-dom-helpers
ember-native-dom-helpers copied to clipboard
Add a `pressKey` helper?
How about adding a pressKey helper which fires keydown, keypress and then keyup?
EDIT: Updated helper name.
@leizhao4 did you notice the example in the README that shows keyEvent ? https://github.com/cibernox/ember-native-dom-helpers#usage
keyEvent('.other-input', 'keyup', 40); // down arrow
Actually having a single helper that simulates a full key interation (fires keydown, keyup and keypress in sequence) sounds reasonable, the same way click fires mousedown, focus, mouseup and click in sequence.
I'd call it pressKey tho, but it sounds reasonable.
I created the under consideration label and added to this issue. To see what other think. I'm personally :+1:, but I don't feel strongly either way.
Yes that's exactly what I mean. After playing around with keyboard events (in Chrome), it looks more complex than I expected and I think there's plenty of room for a new helper.
The events seems to fire in this sequence:
keydown.beforeinput- Only for keys which produce a character value.keypress- Legacy event. Device dependent. Only for keys which produce a character value.input- Only for keys which have updated the DOM.keyup.
Sources:
There are also combinations, for example, a Cmd-Shift-4 would fire three keydowns, one beforeinput, one input, and three keyups.
I'm in favor, though I would rather see pressKey also.
Green light then for someone to implement it.