Home > Web Front-end > JS Tutorial > js function to block F1~F12 shortcut keys_javascript skills

js function to block F1~F12 shortcut keys_javascript skills

WBOY
Release: 2016-05-16 18:28:00
Original
1459 people have browsed it
Copy code The code is as follows:

function window.onhelp(){return false} //Shield F1 help
/*keyCod disables the F2-F12 keys from 113-123 respectively, 13 disables the Enter key (Enter), and 8 disables the Backspace key (BackSpace)*/

document.onkeydown = function (){
if(window.event && window.event.keyCode == 113) {
window.event.keyCode = 505;
}
if(window.event && window.event. keyCode == 114) {
window.event.keyCode = 505;
}
if(window.event && window.event.keyCode == 115) {
window.event.keyCode = 505 ;
}
if(window.event && window.event.keyCode == 116) {
window.event.keyCode = 505;
}
if(window.event && window. event.keyCode == 117) {
window.event.keyCode = 505;
}
if(window.event && window.event.keyCode == 118) {
window.event.keyCode = 505;
}
if(window.event && window.event.keyCode == 119) {
window.event.keyCode = 505;
}
if(window.event && window.event.keyCode == 120) {
window.event.keyCode = 505;
}
if(window.event && window.event.keyCode == 121) {
window.event .keyCode = 505;
}
if(window.event && window.event.keyCode == 122) {
window.event.keyCode = 505;
}
if(window. event && window.event.keyCode == 123) {
window.event.keyCode = 505;
}
if(window.event && window.event.keyCode == 13) {
window .event.keyCode = 505;
}
if(window.event && window.event.keyCode == 8) {
alert(str "nPlease use the Del key to delete characters! ");
window.event.returnValue=false;
}
if(window.event && window.event.keyCode == 505){
 alert(str)
window.event .returnValue=false;
}
}
Related labels:
f12
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template