I have the following in jquery code:
$(document).keypress(function (e) {
if (e.keyCode == 13) {
}
});
How can I make this into javascript so I do not need to load jquery everyime?
document.onkeypress = function (e) {
if (!e) var e = window.event;
var keyCode = e.keyCode || e.which;
if(keyCode == 13) {
}
...
}
Reading:
e = e || window.event;. quirksmode.org/js/keys.html might be interesting to read as well.event parameter passed to the function, and some use window.event. jQuery makes cross browser stuff easy by taking care of that for you.