docs.unity3d.com
    Show / Hide Table of Contents

    On Keyboard Input node

    Note

    The On Keyboard Input node is an Input Manager node. For more information about how to use the Input Manager with Visual Scripting, see Capture user input in an application.

    The On Keyboard Input node listens for a specified action on a keyboard key. It triggers the next node connected to it after the action occurs in the application. It doesn't send or receive any other data.

    An image of the Graph window. An On Keyboard Input node displays with its details in the Graph Inspector.

    Fuzzy finder category

    The On Keyboard Input node is in the Events > Input category in the fuzzy finder.

    Inputs

    The On Keyboard Input node has the following input ports:

    Name Type Description
    Key Key Code The name of the keyboard key the node listens to for an Input event. For a list of all available keys, see the KeyCode page's Properties section in the Unity User manual.
    Action Press State The specific press state of the key that the node listens for.
    Hold The user holds down the key.
    Down The user presses the key.
    Up The user releases the key.

    Additional node settings

    The On Keyboard Input node has additional settings. Access these settings from the Graph Inspector:

    Name Type Description
    Coroutine Toggle Enable Coroutine if you want Visual Scripting to run this node and any of its connected nodes as a coroutine. Coroutine nodes don't execute all their code in a single frame, so they can spread an effect over several frames. Coroutines can also help optimize your code. For more information on coroutines, see the Unity User Manual section on Coroutines.

    Outputs

    The On Keyboard Input node has one output port:

    Name Type Description
    Trigger Output Trigger The control output port. Make a connection to specify what Visual Scripting should do after the configured Input event occurs in your application.

    Example graph usage

    In the following example, the On Keyboard Input node listens for when the user presses the Space key. When the user presses Space, the On Keyboard Input triggers the Transform Translate node and lifts the GameObject along its Y coordinate by 5 units. This makes the GameObject jump.

    An image of the Graph window. An On Keyboard Input node uses inline values to assign its Key as Space and its Action as Down. Its Trigger output port connects to the Invoke input port on a Transform Translate node. The Translate node uses an inline value of This for its Target, and an inline value of 5 for its Y input.

    An image of the Game view. A cylinder and square sit on a plane, with a sphere lifted into the air between them.

    Related nodes

    The following nodes are related or similar to the the On Keyboard Input node:

    • On Button Input node
    • On Mouse Down node
    • On Mouse Drag node
    • On Mouse Enter node
    • On Mouse Exit node
    • On Mouse Input node
    • On Mouse Over node
    • On Mouse Up node
    • On Mouse Up As Button node
    In This Article
    • Fuzzy finder category
    • Inputs
    • Additional node settings
    • Outputs
    • Example graph usage
    • Related nodes
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023