| Ultrashock Forums
• Browser - Disable CTRL key |
Member Blogs | ||
![]() |
||||
| Search this Thread | Thread Tools | Display Modes |
|
|
|||||||||||||||||||||||||
![]() |
Ultrashock Member Comments:
45 Blog Entries
27 Creative Assets
|
2008-01-20
#2 |
||
|
|
2008-01-20
#3 |
||
|
Thanks Anik, I'm using it now but it doesn't work in IE7... The script is this one: Code:
<script language="JavaScript">
function disableCtrlKeyCombination(e)
{
//list all CTRL + key combinations you want to disable
var forbiddenKeys = new Array(‘a’, ‘n’, ‘c’, ‘x’, ‘v’, ‘j’);
var key;
var isCtrl;
if(window.event)
{
key = window.event.keyCode; //IE
if(window.event.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
else
{
key = e.which; //firefox
if(e.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
//if ctrl is pressed check if other key is in forbidenKeys array
if(isCtrl)
{
for(i=0; i<forbiddenkeys .length; i++)
{
//case-insensitive comparation
if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase())
{
alert(‘Key combination CTRL + ‘
+String.fromCharCode(key)
+‘ has been disabled.’);
return false;
}
}
}
return true;
}
</script>
Code:
<body onkeypress="return disableCtrlKeyCombination(event);" onkeydown="return disableCtrlKeyCombination(event);" leftMargin="0" topMargin="0"> Thanks |
|
| Thread Tools | |
| Display Modes | Rate This Thread |
|




2 comments
| 1341 views


45 Blog Entries
27 Creative Assets
Linear Mode
AS Workshop Disable ctrl + n and other ctrl + key combinations in JavaScript