using
window.addEventListener('deviceorientation', handleOrientation); to listen for device orientation
I know I need to find the alpha of device (0 - 360) but don't know what range to use to find out if the phone is in landscape mode
You should check the alpha value from the event.
function handleOrientation (event) { if (event.alpha>89 && event.alpha<150) {//the device is landscape at 90 console.log("Device is landscape"); }; }
deviceorientationevent which none of the answers provide, but rather suggest other events. Those are not going to work for a PWA and onlydeviceorientationwill work. So I request to reopen this.