how to disable a keyboard key

hi everybody,

can you explain or give me the script whitch can disable keyboard key?

thank you for your response.

you can not disable a key but you can just not react to it beeing pressed

You could do something like this:

    private string text = "I bet you can't type an A!";

    void DisableKey( KeyCode key )
    {
        if( Event.current.keyCode == key  ( Event.current.type == EventType.KeyUp || Event.current.type == EventType.KeyDown ) )
        {
            Event.current.Use();
        }
    }

    void OnGUI()
    {
        DisableKey( KeyCode.A );
        text = GUILayout.TextArea( text );
    }

can we do a javascript version of this?
I'm working on it, but don't know much outside of javascript. :sweat_smile:

   private var text = "I bet you can't type an A!"; 

   function DisableKey( key : KeyCode ) 
   { 
      if( Event.current.keyCode == key  ( Event.current.type == EventType.KeyUp || Event.current.type == EventType.KeyDown ) ) 
      { 
         Event.current.Use(); 
      } 
   } 

   function OnGUI()
   { 
      DisableKey( KeyCode.A ); 
      text = GUILayout.TextArea( text ); 
   }

I also did a modified version for a blog post here (C# though): http://angryant.com/2009/09/07/i-bet-you-cant-type-an-a/

thanks man, awesome stuff!

Strange... It works, but only in the editor. Compiled code responds to the key :|