Step1: To disable tab key press on a html body you need to make a html page with some html fields.
the code will be like
<!DOCTYPE html>
<html>
<head>
<title>Disable Tab Key</title>
</head>
<body>
<script type="text/javascript">
document.onkeydown = function (e) {
if(e.which == 9){
return false;
}
}
</script>
<input type="text"><br/>
<input type="text"><br/>
<input type="text"><br/>
<input type="text"><br/>
<input type="text">
</body>
</html>
Step 2: Now make a javascript onkeydown event function with pass the event
the code shall be like
document.onkeydown = function (e) {
}
Step 3: Now have to detect the key value (the tab key vaue is 9)
the keyword for detact value is
e.which //here e is the event passed through the function
Step 4: now if satisfy the condition make return false
code will be something like
if(e.which == 9){
return false;
}
Now the full code will be:
<!DOCTYPE html>
<html>
<head>
<title>Disable Tab Key</title>
</head>
<body>
<script type="text/javascript">
document.onkeydown = function (e) {
if(e.which == 9){
return false;
}
}
</script>
<input type="text"><br/>
<input type="text"><br/>
<input type="text"><br/>
<input type="text"><br/>
<input type="text">
</body>
</html>
Thanks for reading.
the code will be like
<!DOCTYPE html>
<html>
<head>
<title>Disable Tab Key</title>
</head>
<body>
<script type="text/javascript">
document.onkeydown = function (e) {
if(e.which == 9){
return false;
}
}
</script>
<input type="text"><br/>
<input type="text"><br/>
<input type="text"><br/>
<input type="text"><br/>
<input type="text">
</body>
</html>
Step 2: Now make a javascript onkeydown event function with pass the event
the code shall be like
document.onkeydown = function (e) {
}
Step 3: Now have to detect the key value (the tab key vaue is 9)
the keyword for detact value is
e.which //here e is the event passed through the function
Step 4: now if satisfy the condition make return false
code will be something like
if(e.which == 9){
return false;
}
Now the full code will be:
<!DOCTYPE html>
<html>
<head>
<title>Disable Tab Key</title>
</head>
<body>
<script type="text/javascript">
document.onkeydown = function (e) {
if(e.which == 9){
return false;
}
}
</script>
<input type="text"><br/>
<input type="text"><br/>
<input type="text"><br/>
<input type="text"><br/>
<input type="text">
</body>
</html>
Thanks for reading.