Screen Orientation API
The Screen Orientation API allows you to check the current orientation of the screen and even lock it to a specific orientation.
async function lockHandler() {
await screen.orientation.lock("portrait");
}
function releaseHandler() {
screen.orientation.unlock();
}
function getOrientation() {
return screen.orientation.type;
}