- This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
Viewing 10 posts - 1 through 10 (of 10 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › jQuery .keypress(); event help!
Hey, so I’m making an app where when you type text into the
My problems:
When the key is pressed, it displays the text I want, but it also displays the letter “a”. I just want it to display the text I gave it.
When I hold down the key, it doesn’t repeat the text.
After you press a key, you need to refresh the page to start over, so you can’t delete the text.
here is the link :: http://jsfiddle.net/tG8py/
jsfiddle works if you include jQuery.
Preventing the letter ‘a’ to show is easy with `preventDefault()`. By the way, the letter a would be `01100001`.
Actually here’s an even better one with automatic keyCode conversion:
EDIT: Actually use `this.value = keyCode;` instead of innerHTML, innerHTML bugs if you use backspace or something.
Thanks mate! Is there a way to make it so you can press it more than once?
Do you want to append new keycodes to the old one or replace the old one?
Ahh, I was just thinking that! I need to append(); pls. Thanks for helping me, I’m a beginner. ;)
Easy: http://jsfiddle.net/tG8py/3/ as long as the user doesn’t use backspace since backspace removes only 1 bit, would be nice if it removed 8 :)
Thanks a lot man!
No problem :)
I was already demotivated by backspace not triggering a keypress, nice to see keydown does work :)