Search Unity

Detect if a certain key was pressed

Discussion in 'Input System' started by stechmann, Feb 18, 2021.

  1. stechmann

    stechmann

    Joined:
    Feb 24, 2012
    Posts:
    34
    I want to write something like this:

    UnityEngine.InputSystem.Key key;

    if ( Keyboard.current.wasPressedThisFrame(key) ) ...

    I do NOT want to use Actions / bindings.

    Is this possible, what would be the syntax?
     
  2. stechmann

    stechmann

    Joined:
    Feb 24, 2012
    Posts:
    34
    yes, thank you!

    the syntax is

    Keyboard.current[key].wasPressedThisFrame