Skip to content

Update Key Modifiers to suggest KeyboardEvent.key #1850

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

Merged
merged 4 commits into from
Jan 28, 2019
Merged

Conversation

naclonts
Copy link
Contributor

Fixes #1765.

I left the "define custom key modifier aliases" section at the bottom, below the deprecated key codes information. Definitely open to changing / re-arranging as needed!


<!-- also works for shorthand -->
<input @keyup.enter="submit">
The usage of `keyCode` attributes is deprecated, but can be used if needed:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better approach here IMHO would be using some p.tip as a warning instead. Linking "deprecated" to the MDN article would also be nice.

@phanan
Copy link
Member

phanan commented Oct 22, 2018

Very nice :) Just a bit of change and this should be golden (for me at least).

phanan and others added 2 commits October 22, 2018 21:25
@naclonts
Copy link
Contributor Author

Just made the updates, let me know if there's any other adjustments you'd recommend.

@phanan phanan merged commit 67766e4 into vuejs:master Jan 28, 2019
@phanan
Copy link
Member

phanan commented Jan 28, 2019

Thanks!

<!-- only call `vm.submit()` when the `keyCode` is 13 -->
<input v-on:keyup.13="submit">
<!-- only call `vm.submit()` when the `key` is PageDown -->
<input @keyup.page-down="onPageDown">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for late, why here the key becomes PageDown not still Enter? (The keyCode of Enter is 13 and the keyCode of PageDown is 34. Ref: https://keycode.info, https://css-tricks.com/snippets/javascript/javascript-keycodes/)
I think it's better to remain the key Enter is this case to match the meaning of "submit".

Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point @Jinjiang, sorry I missed this. @kokopelli314 would you mind a subsequent PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries I've submitted one here: #1970. @Jinjiang care to take a look? ;)


``` html
<input @keyup.page-down="onPageDown">
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the key PageDown comes from here. Maybe we could rearrange these paragraphs to preserve this code example to show how kebab-case name converted. I will leave more advice for this to PR #1970. @phanan 😉

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

Successfully merging this pull request may close these issues.

3 participants