Help forum

How to listen for combination keyboard events e.g. Shift+Enter

  • Tom Ireland

    2 years ago

    How do you listen for combination keyboard events e.g. Shift+Enter? I can listen for and handle single key presses but cannot figure out how to handle combination. I imagine I need to use a switch like I do for single key presses but not sure of the logic to track both. Do I need a switch followed by another switch?
    ✅1
  • Andreas Møller

    2 years ago

    1179325317479931984-CleanShot_2023-11-29_at_08.37.41.png
  • You can see if "modifier" are held down in the keydown event.
  • if you need complex key combos, like l+i+m you will have to use a variable to keep track of pressed keys
  • Tom Ireland

    2 years ago

    Huzzah! I was so close but I was doing another equals 'Shift' on the AND instead of 'shiftKey'. What a legend! Thanks, @Andreas Møller . 🤘