Skip to content

Commit

Permalink
v1
Browse files Browse the repository at this point in the history
  • Loading branch information
aliraza556 committed Aug 11, 2024
1 parent 009fe23 commit fd3be87
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/ui/fullscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ export class Fullscreen {
if (isFullscreen) {
button.classList.add('fullscreenMode');
}
this.button.addEventListener('click', this.toggle.bind(this));

document.addEventListener('keydown', (event) => {
if (event.shiftKey && event.key === 'F') {
this.toggle();
}
});
}

toggle() {
Expand All @@ -16,29 +21,14 @@ export class Fullscreen {
.querySelectorAll('.fullscreen__title')
.forEach((el) => (el.textContent = 'FullScreen'));
document.exitFullscreen();
} else if (!isAppInNativeFullscreenMode() && window.innerHeight === screen.height) {
alert('Use F11 to exit fullscreen');
} else {
this.button.classList.add('fullscreenMode');
this.button
.querySelectorAll('.fullscreen__title')
.forEach((el) => (el.textContent = 'Contract'));
document.getElementById('AncientBeast').requestFullscreen();
this.triggerF11();
}
}

triggerF11() {
const event = new KeyboardEvent('keydown', {
key: 'F11',
code: 'F11',
keyCode: 122,
which: 122,
bubbles: true,
cancelable: true,
});
document.dispatchEvent(event);
}
}

/**
Expand Down

0 comments on commit fd3be87

Please sign in to comment.