I thought this would be answered somewhere on Stack Overflow, but I can’t find it.
If I’m listening for a keypress event, should I be using .keyCode or .which to determine if the Enter key was pressed?
I’ve always done something like the following:
$("#someid").keypress(function(e) { if (e.keyCode === 13) { e.preventDefault(); // do something } }); But I’m seeing examples that use .which instead of .keyCode. What’s the difference? Is one more cross-browser friendly than the other?