javascript - Prevent browser(Chrome) to run default functions like scroll with space -
i have used 2 functins here first 1 blocking default feature space bar scroll,etc
<span id="current"></span> $("html").on("keydown", function (e) { { e.preventdefault(); } }); document.onkeypress = function(evt) { evt = evt || window.event; var charcode = evt.keycode || evt.which; document.getelementbyid("current").innerhtml=charcode; };
now code works in firefox blocking various default functions of firefox ctrl+a ctrl+s space bar scroll , gives output in span when tried in chrome ,it blocks various default functions of chrome didn't give output in span.
i can write as
document.onkeypress = function(evt) { evt = evt || window.event; var charcode = evt.keycode || evt.which; document.getelementbyid("current").innerhtml=charcode; return false; };
it worked both firfox , chrome function(evt) long , contain many if-else loops , if press double space or press space bar continously scrolls down want alternative solution in can use 2 functions 1 blocking , other outputs , work in chrome.
function (x) { { x = window.event; var cc = evt.keycode ; $('#current').html=cc; x.preventdefault(); return false; } });
Comments
Post a Comment