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

test if there is no key down

Discussion in 'Scripting' started by Jackman, Apr 23, 2009.

  1. Jackman

    Jackman

    Joined:
    Apr 20, 2009
    Posts:
    29
    hi, is it possible to test if there is no key down?
    i don't want to do:
    if(Input.GetKeyUp (KeyCode.UpArrow) Input.GetKeyUp (KeyCode.DownArrow) ....) and this for all the keyboard's keys :?

    thanks in advance
     
  2. Tinus

    Tinus

    Joined:
    Apr 6, 2009
    Posts:
    437
    dpttq likes this.
  3. spiralgear

    spiralgear

    Joined:
    Dec 13, 2007
    Posts:
    528
    I think you could do



    Code (csharp):
    1.  
    2.  
    3. if(!Input.anyKey){
    4.  
    5. //do stuff...
    6.  
    7. }
     
    pratikbaid3 and leonidvartanian like this.
  4. Jackman

    Jackman

    Joined:
    Apr 20, 2009
    Posts:
    29
    Ow so silly!! i've search "input no key" and not "input any key" in the doc :oops:

    thanks a lot :wink:
     
  5. Tinus

    Tinus

    Joined:
    Apr 6, 2009
    Posts:
    437
    The documentation's search function is not as smart as, say, Google. It's best to just type in the one keyword that is most important, in this case 'Input', and browse the results for specific matches. :)
     
    Wiigoof likes this.
  6. Scrat

    Scrat

    Joined:
    Apr 20, 2008
    Posts:
    316
    Or use the handy Google Unity search: http://www.google.com/coop/cse?cx=002470491425767499270:iugs1ezlsfq
     
    SaturnTheIcy likes this.
  7. Tinus

    Tinus

    Joined:
    Apr 6, 2009
    Posts:
    437
    Hey, that's pretty cool. Thanks!
     
  8. JaydedCompanion

    JaydedCompanion

    Joined:
    Jun 24, 2014
    Posts:
    6
    thanks! this helped me a lot (little tip, might wanna put this on unity answers instead of the forum)
     
  9. Akonibai

    Akonibai

    Joined:
    May 17, 2020
    Posts:
    1
    Thanks i used this in a way if you press no key slow motion will activate :D
     
  10. Navaneetorigin

    Navaneetorigin

    Joined:
    Jun 17, 2020
    Posts:
    3
    You can use
    void Update()
    {
    if(Input.anyKey)
    {
    Animator.SetBool("Anykey", false);
    }
    }
    it is just an example
     
  11. Johan_Liebert123

    Johan_Liebert123

    Joined:
    Apr 15, 2021
    Posts:
    474