What is fscreen?
The fscreen npm package provides a simple and consistent API for working with the Fullscreen API across different browsers. It allows developers to easily request fullscreen mode, exit fullscreen mode, and handle fullscreen change events.
What are fscreen's main functionalities?
Request Fullscreen
This feature allows you to request fullscreen mode for a specific element. In this example, clicking anywhere on the document will request fullscreen mode for the entire document.
document.addEventListener('click', () => {
fscreen.requestFullscreen(document.documentElement);
});
Exit Fullscreen
This feature allows you to exit fullscreen mode. In this example, pressing the 'Escape' key will exit fullscreen mode.
document.addEventListener('keydown', (event) => {
if (event.key === 'Escape') {
fscreen.exitFullscreen();
}
});
Fullscreen Change Event
This feature allows you to handle fullscreen change events. In this example, a message is logged to the console whenever the fullscreen mode is entered or exited.
fscreen.addEventListener('fullscreenchange', () => {
if (fscreen.fullscreenElement) {
console.log('Entered fullscreen mode');
} else {
console.log('Exited fullscreen mode');
}
});
Other packages similar to fscreen
screenfull
Screenfull is a simple wrapper for the Fullscreen API that provides a more user-friendly API. It offers similar functionalities to fscreen, such as requesting and exiting fullscreen mode, and handling fullscreen change events. Screenfull also includes additional features like checking if fullscreen is supported and if an element is currently in fullscreen mode.
Fscreen - Fullscreen API

Demo website (demo code on the gh-pages
branch)
Vendor agnostic access to the Fullscreen API. Build with the Fullscreen API as intended without worrying about vendor prefixes.
$ npm install --save fscreen
import fscreen from 'fscreen';
fscreen.fullscreenEnabled === true / false;
fscreen.fullscreenElement === null / undefined / DOM Element;
fscreen.requestFullscreen(element);
fscreen.requestFullscreenFunction(element);
fscreen.exitFullscreen();
fscreen.onfullscreenchange = handler;
fscreen.addEventListener('fullscreenchange', handler, options);
fscreen.removeEventListener('fullscreenchange', handler, options);
fscreen.onfullscreenerror = handler;
fscreen.addEventListener('fullscreenerror', handler, options);
fscreen.removeEventListener('fullscreenerror', handler, options);
fscreen.fullscreenPseudoClass;
Usage
Use it just like the spec API.
if (fscreen.fullscreenEnabled) {
fscreen.addEventListener('fullscreenchange', handler, false);
fscreen.requestFullscreen(element);
}
function handler() {
if (fscreen.fullscreenElement !== null) {
console.log('Entered fullscreen mode');
} else {
console.log('Exited fullscreen mode');
}
}