Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a pressKey helper? #42

Open
leizhao4 opened this issue Mar 22, 2017 · 6 comments
Open

Add a pressKey helper? #42

leizhao4 opened this issue Mar 22, 2017 · 6 comments

Comments

@leizhao4
Copy link

leizhao4 commented Mar 22, 2017

How about adding a pressKey helper which fires keydown, keypress and then keyup?

EDIT: Updated helper name.

@pixelhandler
Copy link
Collaborator

@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

@cibernox
Copy link
Owner

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.

@cibernox
Copy link
Owner

I created the under consideration label and added to this issue. To see what other think. I'm personally 👍, but I don't feel strongly either way.

@leizhao4
Copy link
Author

leizhao4 commented Mar 22, 2017

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:

  1. keydown.
  2. beforeinput - Only for keys which produce a character value.
  3. keypress - Legacy event. Device dependent. Only for keys which produce a character value.
  4. input - Only for keys which have updated the DOM.
  5. keyup.

Sources:

There are also combinations, for example, a Cmd-Shift-4 would fire three keydowns, one beforeinput, one input, and three keyups.

@rwjblue
Copy link
Collaborator

rwjblue commented Mar 22, 2017

I'm in favor, though I would rather see pressKey also.

@leizhao4 leizhao4 changed the title Add a press helper? Add a pressKey helper? Mar 22, 2017
@cibernox
Copy link
Owner

Green light then for someone to implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants