[RESOLVED]What's the best practice to catch key events?

Hi all,

I am playing around trying to limit what characters and the number of certain characters that can be entered in my textbox field. I have tried onkeydown, onkeypress and onkeyup with differing degrees success depending on which browser I am in. With none
truly satisfactory for android mobile.

Therefore I was wondering what is best practice for multi browser/platform compatability?

Did you try jquery? It should work with keyup as well as it supports all mouse/touch events for most of mobile devices http://jquerymobile.com/gbs/1.4/ 

Check this page on your mobile device: http://jsbin.com/aNEBIKA/2/ 

Source: http://stackoverflow.com/questions/21113050/jquery-mobile-keyup-keydown-on-mobile-devices 

I am using jquery and as I said it’s only firefox and mobile that i’m having issues. Firefox deletes previous two characters when i’m deleting a hyphen (other character deletions seem to only delete the one character) and mobile i’m wondering if I need to
add some sort of delay to it as it does look like it may be working but i’m typing to quick for it to handle the suppression of keys.

If I go on mobile (Android) to the above link at jsbin it does count every "click". What’s wrong?

Leave a Reply