Friends I was making a calculator like project so It is a full webpage that displays my calculator. For inputs from keyboard all other keys worked. And I also want to use backspace key to do [del] command as in calculator. But it always goes to Backward visited site. Here’s my code:
$(document).keypress(function(e){
var e=window.event || e
var keyunicode=e.charCode || e.keyCode
if(keyunicode>=40 && keyunicode<=57 && keyunicode!=44)
{
//call a function [worked]
}
else if(keyunicode==61)
{
// call another function worked.
}
else if(keyunicode==8)
{
e.preventDefault();
delete_last();
return false;
}
});
Please help. I tried in chrome..
You should use a
keydownlistener to catch backspace.keypressis meant for character keys.keydownis useful for functional keys.