Home > Web Front-end > JS Tutorial > body text

JS sample code for blocking key effects and changing key effects_javascript skills

WBOY
Release: 2016-05-16 17:07:27
Original
1052 people have browsed it

Function keys F1-F2: 112-123

a-b: 65-90

Number keys: 0-9: 48-57

ESC: 27

Backspace key: 8

Enter: 13

shift: 16; Ctrl: 17; Alt: 18

Space: 32

Insert: 45; Delete: 46

Copy code The code is as follows:

function document .onkeydown(){ //Triggered by pressing Enter in the webpage
if(event.keyCode==13)
{
document.getElementById("loginbtn").click();
return false;                                         

document.onkeydown=MM_KeyPress;

function MM_KeyPress(num){

//Prevent the system backspace key

var keycode = event.keyCode;

if(keycode ==8)//Shield the backspace key
{

event.keyCode = 0;
//event.returnValue=false;

return;

}
if(keycode >=112 && keycode <=123)//Shield f1 -12 function keys
{

event.keyCode = 0 ;
event.returnValue=false;

return;

}
}


Related labels:
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