By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,518 Members | 886 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,518 IT Pros & Developers. It's quick & easy.

disable ctrl+s

P: 1
The below code is to disable the ctrl+s functionality and triger to user defined function when we press ctrl+s...It is working fine in IE. In mozilla also its working fine but the problem here is, letter "S" is diabled when i want to add any word which is including "S" is not posiible in mozilla.

can any one please help on this.
Expand|Select|Wrap|Line Numbers
  1. document.onkeydown = disablekey;
  2. document.onhelp=processHelp;
  3. function disablekey(evtArg)
  4. {
  5.     var isIE = ( document.all ? true : false) ;
  6.     var KeyID=( document.all ? window.event.keyCode : evtArg.which) ;
  7.     var ctrlPressed =( document.all ? window.event.ctrlKey: evtArg.which);
  8.     if ( ctrlPressed && KeyID == 83 )
  9.     {
  10.         if( isIE )
  11.         {
  12.             handleKey(evtArg);
  13.             event.keyCode = 0;
  14.             return false;
  15.         }
  16.         else
  17.         {
  18.             handleKey(evtArg);
  19.             evtArg.preventDefault();
  20.             evtArg.stopPropagation();
  21.         }
  22.     }
  23.     else
  24.     {
  25.         handleKey(evtArg);
  26.     }
  27.  
  28. }
  29. function handleKey(evtArg)
  30. {    
  31.     var evt = ( document.all ? window.event : evtArg) ;
  32.     var isIE = ( document.all ? true : false) ;
  33.     var KeyID=( document.all ? window.event.keyCode : evtArg.which) ;
  34.     var skip=false;
  35.     ctrlPressed = evt.ctrlKey; 
  36.     //var ctrlPressed =( document.all ? window.event.ctrlKey: evtArg.which);
  37.     if( ctrlPressed && KeyID == 83 )
  38.     {    
  39.  
  40.         if(document.MAINFORM.activity.value=="CREATE_ORDER_CONFIRMATION")
  41.         {
  42.         completeCreateOrderConfirmation();
  43.  
  44.             if(!skip)
  45.             {
  46.  
  47.             if ( isIE )
  48.             {
  49.                 event.keyCode = 0;
  50.                 event.returnValue = false;
  51.                 return false;
  52.  
  53.             }
  54.             else
  55.             {
  56.                 evt.preventDefault();
  57.                 evt.stopPropagation();
  58.             }
  59.             } 
  60.     }
  61. }
  62. function processHelp()
  63. {
  64.     return false;
  65. }
Jun 23 '11 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
how do you know that the control key has been pressed in Mozilla?
Jun 23 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.