Search Unity

Keyboard.key.wasPressedThisFrame resets each frame in EditorWindow

Discussion in 'Input System' started by Sarkahn, Apr 14, 2020.

  1. Sarkahn

    Sarkahn

    Joined:
    Jan 9, 2013
    Posts:
    440
    Hello, I'm trying to make editor controls that rely on keyboard presses. But inside an EditorWindow
    Keyboard.key.wasPressedThisFrame
    always returns true if the key is held down, instead of returning false after the first frame. This is using preview 6 in Unity 2020.1.0b5:

    Added to the "EditorWindowDemo" sample:
    Code (CSharp):
    1.         var keyboard = Keyboard.current;
    2.         if (keyboard == null)
    3.             return;
    4.  
    5.         EditorGUILayout.LabelField($"A key was pressed this frame: {keyboard.aKey.wasPressedThisFrame}");
    The result when I press and hold the A key:
    XCoQSniXCG.gif