disable ctrl+s

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lavanya r
    New Member
    • Jun 2011
    • 1

    disable ctrl+s

    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.
    Code:
    document.onkeydown = disablekey;
    document.onhelp=processHelp;
    function disablekey(evtArg)
    {
    	var isIE = ( document.all ? true : false) ;
    	var KeyID=( document.all ? window.event.keyCode : evtArg.which) ;
    	var ctrlPressed =( document.all ? window.event.ctrlKey: evtArg.which);
    	if ( ctrlPressed && KeyID == 83 )
    	{
    		if( isIE )
    		{
    			handleKey(evtArg);
    			event.keyCode = 0;
    			return false;
    		}
    		else
    		{
    			handleKey(evtArg);
    			evtArg.preventDefault();
    			evtArg.stopPropagation();
    		}
    	}
    	else
    	{
    		handleKey(evtArg);
    	}
    	
    }
    function handleKey(evtArg)
    {	
    	var evt = ( document.all ? window.event : evtArg) ;
    	var isIE = ( document.all ? true : false) ;
    	var KeyID=( document.all ? window.event.keyCode : evtArg.which) ;
    	var skip=false;
    	ctrlPressed = evt.ctrlKey; 
    	//var ctrlPressed =( document.all ? window.event.ctrlKey: evtArg.which);
    	if( ctrlPressed && KeyID == 83 )
    	{	
    		
    		if(document.MAINFORM.activity.value=="CREATE_ORDER_CONFIRMATION")
    		{
    		completeCreateOrderConfirmation();
    
    			if(!skip)
    			{
    			
    			if ( isIE )
    			{
    				event.keyCode = 0;
    				event.returnValue = false;
    				return false;
    				
    			}
    			else
    			{
    				evt.preventDefault();
    				evt.stopPropagation();
    			}
    			} 
    	}
    }
    function processHelp()
    {
    	return false;
    }
    Last edited by Meetee; Jun 23 '11, 06:58 AM. Reason: Please use code tags [CODE][/CODE]
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    how do you know that the control key has been pressed in Mozilla?

    Comment

    Working...