Esc key exitst fullscreen

pull/5307/head
LEWE, GEORGE 1 year ago
parent e0e343e743
commit 4d78600b11

@ -28,6 +28,7 @@ const SELECTOR_MINIMIZE_ICON = '[data-lte-icon="minimize"]'
*/
class FullScreen {
_element: HTMLElement
constructor(element: HTMLElement) {
this._element = element
}
@ -86,6 +87,18 @@ onDOMContentLoaded(() => {
}
})
})
document.addEventListener('keydown', event => {
event.preventDefault()
if (event.key === 'Escape' && document.fullscreenEnabled) {
const target = event.target as HTMLElement
const fsButton = target.closest(SELECTOR_FULLSCREEN_TOGGLE) as HTMLElement | undefined
if (fsButton) {
const data = new FullScreen(fsButton)
data.toggleFullScreen()
}
}
})
})
export default FullScreen

Loading…
Cancel
Save