- Home /
 
              This question was 
             closed May 12, 2013 at 01:59 AM by 
             TheDarkVoid for the following reason: 
             
 
            Other
 
               Question by 
               TheDarkVoid · Jul 14, 2012 at 12:10 AM · 
                c#inputkeycode  
              
 
              Key binding screen
i am trying to create a menu that would allow users to modify key bindings. here is the code i have: GUI:
 GUI.Label(new Rect(50, 0, 100, 20), "Zoom Out:");
 if(GUI.Button(new Rect(200, 0, 200, 20), ZoomOutTxt))
 {
  L_ZoomOut = true;
  ZoomOutTxt = "Press a Key.";
  Screen.lockCursor = true;
 }
 //ZoomIn
 GUI.Label(new Rect(50, 20, 100, 20), "Zoom In:");
 if(GUI.Button(new Rect(200, 20, 200, 20), ZoomInTxt))
 {
  L_ZoomIn = true;
  ZoomInTxt = "Press a Key.";
  Screen.lockCursor = true;
 }
 
               the input listener in the Update()
 if(L_ZoomOut)
 {
  if(CheckKey(e.keyCode))
  {
  ZoomOut = (int)e.keyCode;
  ZoomOutTxt = ((KeyCode)ZoomOut).ToString();
  Screen.lockCursor = false;
  L_ZoomOut = false;
  }else
  {
  L_ZoomOut = false;
  ZoomOut = PlayerPrefs.GetInt("ZoomOUT", D_ZoomOut);
  ZoomOutTxt = ((KeyCode)ZoomOut).ToString();
  Screen.lockCursor = false;
  }
 }
 if(L_ZoomIn)
 {
  if(CheckKey(e.keyCode))
  {
  ZoomIn = (int)e.keyCode;
  ZoomInTxt = ((KeyCode)ZoomIn).ToString();
  Screen.lockCursor = false;
  L_ZoomIn = false;
  }else
  {
  L_ZoomIn = false;
  ZoomIn = PlayerPrefs.GetInt("ZoomIN", D_ZoomIn);
  ZoomInTxt = ((KeyCode)ZoomIn).ToString();
  Screen.lockCursor = false;
  }
 }
 
               this key checker:
 bool CheckKey(KeyCode key)
 {
  if(ForbiddenKeys.Contains((int)key))
  {
  return false;
  }else
  {
  return true;
  }
 }
 
               the problem is when i click the button it changes to None the list of forbidden keys are as follows: escape, capslock, f1 - f12, and mouse0 as keycodes any suggestions.
               Comment
              
 
               
              Follow this Question
Related Questions
C# Script Simulating Input.inputString 0 Answers
Last key pressed 1 Answer
Issue With Lists and Keycodes 1 Answer
Dynamic KeyCode Unity Exception 2 Answers