Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

Remove depreciated Keypress event that doesn't work on android browsers #71

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

lain-d
Copy link

@lain-d lain-d commented Feb 7, 2018

This branch update removes the onkeypress event.

Most logic is moved into the on keydown event.

At the onkeydown event, the current value of the typer is cached, then at the "input" event the current value is compared to the cached value, this will result in whatever the last character typed was, this character is inserted.

All control keys retain functionality.

Tested on Chrome, Android Chrome, iOS safari.

Thanks to this article for the inspiration for a solution!

https://www.outsystems.com/blog/javascript-events-unmasked-how-to-create-input-mask-for-mobile.html

…evices,

now will listen for onkeydown event, get current input value, then on "input" event get the new input value, figure out what character was added, and then add that new character to the console display, tested and works. thanks to this article : https://www.outsystems.com/blog/javascript-events-unmasked-how-to-create-input-mask-for-mobile.html
@luchotc
Copy link

luchotc commented Feb 8, 2018

Hi @dan2600. I've been testing this and apparently everything is working as expected. I would love to see this one merged.

I would suggest to re order the code a bit, so the diff between the new version and the previous one isn't so big. This way the real changes are hard to track.
Also i think you meant deprecated on the title.

Thanks for this fix!

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

Successfully merging this pull request may close these issues.

2 participants