Search code examples
internet-explorer-6kiosk

Disable Specific Keys in IE 6


I need to disable specific keys (Ctrl and Backspace) in Internet Explorer 6. Is there a registry hack to do this. It has to be IE6. Thanks.

Long Edit:

@apandit: Whoops. I need to more specific about the backspace thing. When I say disable backspace, I mean disable the ability for Backspace to mimic the Back browser button. In IE, pressing Backspace when the focus is not in a text entry field is equivalent to pressing Back (browsing to the previous page).

As for the Ctrl key. There are some pages which have links which create new IE windows. I have the popup blocker turned on, which block this. But, Ctrl clicking result in the new window being launched.

This is for a kiosk application, which is currently a web based application. Clients do not have the funds at this time to make their site kiosk friendly. Things like URL filtering and disabling the URL entry field is already done.

Thanks.


Solution

  • For what purpose do you need this? Because disabling the backspace would be hell for typing urls or emails, etc.

    We could recommend other workarounds if we knew the problem better.

    EDIT 1:
    This website seems to have some information as to how it's done. I can't verify it currently, but I'll look into it: http://www.ozzu.com/programming-forum/disable-key-and-back-t44867.html

    Edit 2:
    This website has some key codes: http://www.advscheduler.com/docs/manual/type_sendkeys.html It seems BACKSPACE is 08.

    EDIT 3:
    Found some more code for blocking, check this out:

    
    <script type="text/javascript">var sType = "keypress";</script> 
    
    <!--[if IE]> 
    <script type="text/javascript">sType = "keydown";</script> 
    <![endif]--> 
    
    <script type="text/javascript"> 
    fIntercept = function(e) { 
       // alert(e.keyCode);
      e = e || event.e; 
      if (e.keyCode == 116) { 
       // When F5 is pressed 
       fCancel(e); 
      } else if (e.ctrlKey && (e.keyCode == 0 || e.keyCode == 82)) { 
       // When ctrl is pressed with R 
       fCancel(e); 
      } 
    }; 
    
    fCancel = function(e) { 
      if (e.preventDefault) { 
       e.stopPropagation(); 
       e.preventDefault(); 
      } else { 
       e.keyCode = 0; 
       e.returnValue = false; 
       e.cancelBubble = true; 
      } 
      return false; 
    }; 
    
    fAddEvent = function(obj, type, fn) { 
      if (obj.addEventListener) { 
       obj.addEventListener(type, fn, false); 
      } else { 
       obj['e'+type+fn] = fn; 
       obj[type+fn] = function() { 
        obj['e'+type+fn](window.event); 
       } 
       obj.attachEvent('on'+type, obj[type+fn]); 
      } 
    }; 
    
    
    fAddEvent(document, sType, fIntercept); 
    </script> 
    

    Ok, now you should have all you need to do it. To disable backspace, the keycode is 08. You can probably just use the code I posted with slight modifications only... :\

    Try it out and see if it's what you needed. (I hope you know how to use Javascript.)