This is one of the simple trick to disable particular keys from keyboard in webpages using javascript, this is one of the way to avoid copying data from our website and etc..
But some of the keys are not working because that was browsers reserved keys, when user disable javascript from browser so these functionality is not working
For example i am taken TAB KEY , Now i will disable the tab keys using javascript.
<html>
<head>
<title>keyboard disable test</title>
<script>
document.onkeydown = function (t) {
if(t.which == 9){
return false;
}
}
</script>
</head>
<body>
<h1>Now press Tab Key and check it...</h1>
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
</form>
</body>
</html>
The 9 is the javascript key code for 'TAB KEY' the below i listed the key numbers and try to put those numbers also. But some of the browser reserved keys are not working.But some of the keys are not working because that was browsers reserved keys, when user disable javascript from browser so these functionality is not working
For example i am taken TAB KEY , Now i will disable the tab keys using javascript.
Disable tab key using Javascript Code:
<html>
<head>
<title>keyboard disable test</title>
<script>
document.onkeydown = function (t) {
if(t.which == 9){
return false;
}
}
</script>
</head>
<body>
<h1>Now press Tab Key and check it...</h1>
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
<input type="text">
</form>
</body>
</html>
|
|
|
0 Comments