JS Shielding keyboard Events

Source: Internet
Author: User

<script>
function KeyDown () {//Mask right mouse button, CTRL + N, SHIFT+F10, F5 refresh, backspace key
Alert ("ASCII code is:" +event.keycode);
if ((Window.event.altKey) &&
((window.event.keycode==37) | |//SHIELD ALT + arrow key ←
(window.event.keycode==39)) ) {//mask ALT + arrow key →
Alert ("Don't use ALT + arrow keys to forward or rewind the page!") ");
Event.returnvalue=false;
}
if ((event.keycode==8) | |//MASK BACKSPACE Delete key
(event.keycode==116) | | Mask F5 Refresh Key
(event.keycode==112) | | Mask F1 Refresh Key
(Event.ctrlkey && event.keycode==82)) {//ctrl + R
event.keycode=0;
Event.returnvalue=false;
Alert ("Don't let you use fast! ");
}
if ((Event.ctrlkey) && (event.keycode==78))//Shielded CTRL + N
{
Alert ("CTRL + N");
Event.returnvalue=false;
}
if ((Event.shiftkey) && (event.keycode==121))//shielded SHIFT+F10
{
Alert ("Shift+f10");
Event.returnvalue=false;
}
if (Window.event.srcElement.tagName = = "A" && Window.event.shiftKey)
{
Window.event.returnValue = false; Screen shift and left mouse button to open a new page
}

if ((Window.event.altKey) && (window.event.keycode==115)) {//shielded ALT+F4
Alert (' Alt+f4 ');
Window.showmodelessdialog ("About:blank", "" "," dialogwidth:1px;dialogheight:1px ");
return false;
}
}
Document.onkeydown = KeyDown
</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.