Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery .keypress(); event help!

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #44811

    Hey, so I’m making an app where when you type text into the

    #135241
    CrocoDillon
    Participant

    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`.

    http://jsfiddle.net/tG8py/1/

    #135242
    CrocoDillon
    Participant

    Actually here’s an even better one with automatic keyCode conversion:

    http://jsfiddle.net/tG8py/2/

    EDIT: Actually use `this.value = keyCode;` instead of innerHTML, innerHTML bugs if you use backspace or something.

    #135243

    Thanks mate! Is there a way to make it so you can press it more than once?

    #135244
    CrocoDillon
    Participant

    Do you want to append new keycodes to the old one or replace the old one?

    #135245

    Ahh, I was just thinking that! I need to append(); pls. Thanks for helping me, I’m a beginner. ;)

    #135246
    CrocoDillon
    Participant

    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 :)

    #135247

    Thanks a lot man!

    #135248
    CrocoDillon
    Participant

    No problem :)

    #135474
    CrocoDillon
    Participant

    I was already demotivated by backspace not triggering a keypress, nice to see keydown does work :)

Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.