Capture ESC key press on full screen mode

A page having option full and exit full icons. When a click event triggered they doing their task correctly and toggle icons, but when ESC key is pressed page will exit from full screen but icons will not toggle. How to handle ESC key events.

const pressKeyHandle = e => {
    if (e.keyCode === 27 || e.key === 'Escape' || e.keyCode === 90 || e.key === 'z') {
      // do something
    }
  }

window.addEventListener(‘keydown’, pressKeyHandle, { once: true })

1 Like

Blaze template events expecting class or ID where events will trigger. But ESC key is not triggering on any specific class or ID.

They don’t you can safely to this

'click' (e, t) => {}

In your events map. It will catch up all events from the template’s Dom scope

3 Likes

I did not know this! that’s great to know I used to have to wrap everything in an element