Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Is there a way to detect KeyDownEvent during a drag?

Discussion in 'UI Toolkit' started by tonycoculuzzi, Dec 18, 2021.

  1. tonycoculuzzi

    tonycoculuzzi

    Joined:
    Jun 2, 2011
    Posts:
    301
    It seems like keyboard events are ignored during drag events. Is there a way to get KeyDownEvent and KeyUpEvent while handling the dragging of an element?
     
  2. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    183
    I think you are right. Let me check that with the team. You can however know from the event itself check if a modifier key is pressed (shift, cmd, alt, etc.); also good to know that a DragUpdatedEvent is sent anytime a key is pressed during the drag.
     
  3. tonycoculuzzi

    tonycoculuzzi

    Joined:
    Jun 2, 2011
    Posts:
    301
    In my case, I'm not looking for a modifier key. Instead, I'm trying to detect if a normal key has been pressed while dragging something (like Delete to remove the dragged selection, R to rotate it, etc)