<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).keydown(function(e){
// alert(e.keyCode);
var elid = $(document.activeElement).is("input:focus");
var downKeyCode = e.keyCode;
// Backspace
if(downKeyCode === 8 && !elid){
e.preventDefault();
}
// ALT
if(e.altKey){
e.preventDefault();
}
// CTRL
if(e.ctrlKey){
e.preventDefault();
}
// 116-F5, 16-SHIFT, 45-INSERT, 122-F11, 123-F12. 118-F7
if(downKeyCode == 116 || downKeyCode == 16 || downKeyCode == 45 || downKeyCode == 122
|| downKeyCode == 123 || downKeyCode == 118 || downKeyCode == 505){
if(downKeyCode == 116 || downKeyCode == 122){
e.keyCode = 505;
e.originalEvent.keyCode = 0;
}
e.preventDefault();
e.stopPropagation();
e.cancelBubble = true;
e.returnValue = false;
$("#inName").val(downKeyCode);
return false;
}
});
</script>
</head>
<body>
<input type="text" value="GOOGLE" name="inName" id="inName"/>
</body>
</html>
No comments:
Post a Comment