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

GetKey

Discussion in 'Scripting' started by nmceri, Aug 13, 2005.

  1. nmceri

    nmceri

    Joined:
    Aug 4, 2005
    Posts:
    56
    I'm having some trouble using GetKey. I'm doing something like this.

    Code (csharp):
    1. function GetKey() {
    2.       //assuming ascii values
    3.    if (Input.GetKey (37)) {
    4.       //do stuff
    5.    }
    6. }
    I'm clearly doing something wrong but i'm totally unable to figure out what the problem is. could anyone shed some light on it?

    edit: code tags
     
  2. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
  3. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    GetKey uses strings to identify keys:
    http://www.otee.dk/Documentation/Manual/Input.html
    See the end of the page.

    Code (csharp):
    1.  
    2. function GetKey() {
    3.       //assuming ascii values
    4.    if (Input.GetKey ("space")) {
    5.       //do stuff
    6.    }
    7. }
    8.  
     
  4. nmceri

    nmceri

    Joined:
    Aug 4, 2005
    Posts:
    56
    I feel a bit silly now. The section on input in the manual is very descriptive. I had just been looking directly at http://otee.dk/Documentation/ScriptReference/Input.html#GetKey scratching my head wondering how to use it, never bothering to scroll up and look at the rest. RTFM I think may have been appropriate here...