Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

KeyDown + KeyUp

Discussion in 'Scripting' started by Findo, Mar 13, 2014.

  1. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    How can you detect when a key is up or down?


    Can you provide the script? thank you
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,618
  3. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
  4. MDragon

    MDragon

    Joined:
    Dec 26, 2013
    Posts:
    329
    You're going to have to learn how to use manuals/references and Google, else you'll be asking questions every day, every moment, with barely any progress.

    And yes, those links are VERY helpful. If you Googled "unity3d keydown" you would have been directed to that page (or the more specific next page), or if you skimmed that page, you would have seen the following line:
    (With this link: https://docs.unity3d.com/Documentation/ScriptReference/Input.GetKeyDown.html)

    If you continue reading, you would see that it takes a paramater called a "KeyCode". If you click on that, you can see how you can call on "Up" and "Down" (and practically every other key on your keyboard)

    Hope that helps (and teaches you a life-long lesson of resourcefulness ;) )

    Edit: Didn't realize the manual was also posted. That helps a ton and comprehensively skimming through that will save work looking this all up again down the road. Hint: Reading it would be a great idea to get how it all works, with examples as well (rather than glancing at it than saying not sure how it works when you didn't comprehensively read it- and no, I'm not blaming you as those manuals look long and painful when starting from scratch as is proper for being called a "manual" :D )
     
    Last edited: Mar 13, 2014
    Hero247 likes this.
  5. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,618
    Oh, because you're still in middle school and haven't been assigned a 'research paper' project yet. And you know... you don't do anything until after you've been told how to do it... instead of being brave and going and INVESTIGATING THE WORLD AROUND YOU.

    Sorry, but the tiny, miniscule, lowest common denominator, amount of effort you put into finding the answer to your question resulted in MORE effort from me then really should have occurred.

    Who am I? Your personal google machine?

    I actually got a tattoo for that a long while back.