i new javascript , want know how call function if control + s depressed on webpage. far have come :
<% document.body.onclick = function(e){ if (e.ctrlkey){ document.body.onclick = function(f){ if(f.keycode = 115){} menubar.saveaction(); } } } if (e.keycode = 115){ document.body.onclick = function(f){ if(f.ctrlkey){} menubar.saveaction(); } } } } %> any appreciated.
like this:
document.addeventlistener("keydown", function(e) { if(e.ctrlkey && e.keycode === 83) { // 83 = s e.preventdefault(); // prevent default browser action alert("ctrl + s"); // code goes here } });
Comments
Post a Comment