keldar
keldar

Reputation: 6252

HTML5 - Android - get key pressed

I am running Android 4.4.2 and it does not seem to fire the 'keypress' event.

Just some basic code I have now for testing is purposes:

$('<input>')
    .on('keyup', function (e) {
        e.preventDefault();
        console.log(e.which);
    })
    .on('keypress', function (e) {
        e.preventDefault();
        console.log(e.which); // never fired
    })
    .on('keyup', function () {
        console.log(e.which);
    });

Yet the 'keyup' and 'keydown' event does not give an accurate code for the actual key pressed.

Is there a method (either JavaScript or jQuery) which I can use to get the actual key pressed in Android?

Thanks.

Upvotes: 0

Views: 181

Answers (1)

the fender
the fender

Reputation: 11

I think it's because of the spell check because the events only fire after a space or enter on android. Maybe find away to turn off spell check or scan the text field manually by focusing on a hidden text box maybe? I'm working on it when I wake up tomorrow.

Upvotes: 1

Related Questions