Skizit
Skizit

Reputation: 44862

'enter' listener not firing on webkit (Chrome)

I've got the following..

    qbox.addEventListener("enter", function(event){
        alert("tap!");
    }, false);

qbox is a textArea basically and whenever I enter the text and hit enter the alert box does not fire. If I replace enter with keydown it works for all of my keydown keys. So, I know the problem is with that particular thing. I want it ideally to fire when ever the user clicks submit or hits enter. I've tried ENTER and submit too but neither work.

Upvotes: 2

Views: 883

Answers (2)

Shaz
Shaz

Reputation: 15877

qbox.addEventListener("keydown", function (event) {

    if (event.keyCode === 13) {
        alert("tap!");
    }

}, false);

Upvotes: 2

Delan Azabani
Delan Azabani

Reputation: 81462

enter is not an event. You should use the keypress event, then check if the key pressed was the enter key.

Upvotes: 0

Related Questions