0

Why does one enter keypress runs (inside) through this code twice?
I've tried keypress, keydown and also event.preventdefault() to no avail.

    $(document).keydown(function (e) {
        if (e.which == 13) {
           alert("0")
            var focado = document.getElementById(document.activeElement.id), fim = focado.id.substring(1),
                inicio = focado.id.substring(0, 1),
                fimseg = fim,
                anterior = inicio + (fim - 1);

            alert("1")


            alert("focado " + focado.id + " fim " + fim + " inicio " + inicio + " fimseg " + fimseg + " anterior " + anterior);
        }
});

and only after giving this 3 messages twice it would continue to the remaining code I trimmed and isn't shown.
thanks

Edited by nosfa: forgot sthing

2
Contributors
1
Reply
18
Views
2 Years
Discussion Span
Last Post by Taywin
0

Hmm... You use it on the whole document? I have a feeling that the event is bubbled from an element inside the page and the whole document. Have you tried to change from $(document) to a specific element and/or $(window) to see if it still acts the same way?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.