I would like to share with you how to use js to shield users from pressing the direction keys (compatible with IE and firefox )! Add the following code to the head and body areas of the source code.
Document. onkeydown = function (e) {e = e | event; // mask the left direction key if (e. keyCode = 37) {alert ('Do not move to the left direction key! '); Return false;} // specifies the direction key for blocking the upward direction. if (e. keyCode = 38) {alert ('prohibit the direction key for upward direction! '); Return false;} // mask the right direction key if (e. keyCode = 39) {alert ('prohibit the right direction key! '); Return false;} // mask the downward direction key if (e. keyCode = 40) {alert ('prohibit downward direction keys! '); Return false ;}}
Articles you may be interested in
- Js shields mouse and keyboard events (including right-click, direction key, backspace key, F5 refresh key, etc.), compatible with IE and firefox
- Javascript shield right-click, compatible with IE and firefox
- Javascript determines whether the mouse is left or right-click-compatible with ie, firefox, chrome, and other major browsers
- Js obtains the height of the scroll bar from the top and bottom of the browser. It is compatible with ie and firefox.
- Js can only enter numbers and numbers with decimal points, compatible with IE and firefox
- Javascript to get the current mouse position (compatible with IE and firefox)
- Js to get the current mouse position, compatible with ie and firefox
- Js obtains the number of rows and columns of a table (compatible with IE and firefox)