Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Some KeyCodes not working

Discussion in 'Scripting' started by yangmeng, Mar 2, 2011.

  1. yangmeng

    yangmeng

    Joined:
    Dec 5, 2006
    Posts:
    573
    Some keycodes are working in a script I have and some are not. For example:
    Code (csharp):
    1. else if (Input.GetKeyDown(KeyCode.Return)){
    works
    but
    Code (csharp):
    1. else if (Input.GetKeyDown(KeyCode.Delete)){
    does not.
    Any ideas why?
     
  2. Jesse Anders

    Jesse Anders

    Joined:
    Apr 5, 2008
    Posts:
    2,857
    Can you post the script in its entirety? (Or at least the function from which the above excerpts were taken?)
     
  3. yangmeng

    yangmeng

    Joined:
    Dec 5, 2006
    Posts:
    573
    Sure.

    Code (csharp):
    1. else if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift)){
    2.         shiftOn = 1;
    3.         highlight.transform.localPosition.x = .04;
    4.     }
    5.     else if (Input.GetKeyDown(KeyCode.CapsLock)){
    6.         print ("CapsLock");
    7.         if (shiftOn < 2){
    8.             shiftOn = 2;
    9.             highlight.transform.localPosition.x = 0.935;
    10.         }
    11.         else {
    12.             shiftOn = 0;
    13.             highlight.transform.localPosition.x = 2;
    14.         }
    15.     }
    16.     else if (Input.GetKeyDown(KeyCode.Delete)){
    17.         DeleteLetter();
    18.     }
    19.     else if (Input.GetKeyDown(KeyCode.Return)){
    20.         WriteBookInfo();
    21.         inputLineText.transform.position.y = 10;
    22.         inputTextBG.transform.position.y = 10;
    23.     }
    24.     else if (Input.GetKeyDown(KeyCode.RightArrow)){
    25.         EditRight();
    26.     }
    27.     else if (Input.GetKeyDown(KeyCode.LeftArrow)){
    28.         EditLeft();
    29.     }
    Delete and Caps lock don't work. The others do.
     
  4. Jesse Anders

    Jesse Anders

    Joined:
    Apr 5, 2008
    Posts:
    2,857
    It doesn't look like you got the whole function in there. (It would be useful to see the function in its entirety.)