8000 Support backspace with "delete" keycode alias by thecrypticace · Pull Request #2211 · vuejs/vue · GitHub
[go: up one dir, main page]

Skip to content

Support backspace with "delete" keycode alias #2211

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

Conversation

thecrypticace
Copy link

Currently when using the delete alias in a on directive with keyup `delete" does not support using backspace. This seems quite counterintuitive. Additionally, on Mac keyboards the key normally identified as "backspace" on PC keyboards is called "delete." I was fairly surprised when using the delete modifier didn't detect the key.

I came upon this when developing a search / tag field that turned a search query into tokens when hitting enter or space. I wanted a way to delete tokens without using the mouse. The solution I came up with was detecting the delete key and removing the last token if the search field was empty. I spent 10 minutes debugging code until I realized that I had to press fn+delete (equivalent of DEL / forward delete on a Mac laptop-sized keyboard) for it to actually remove the token.

You can see a reduced test case / demo of this here: http://codepen.io/thecrypticace/pen/YwGKmJ

This PR makes a change to allow aliases to map to multiple key codes. And, using that, it adds support for delete to react to both backspace and DEL / forward delete.

yyx990803 added a commit that referenced this pull request Jan 22, 2016
…lete-alias

Support backspace with "delete" keycode alias
@yyx990803 yyx990803 merged commit fe02b38 into vuejs:dev Jan 22, 2016
@yyx990803
Copy link
Member

Thanks for the detailed explanation and test coverage 👍

@thecrypticace thecrypticace deleted the support-backspace-with-delete-alias branch January 22, 2016 21:37
@thecrypticace
Copy link
Author

Glad to help.

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.

2 participants
0