files/en-us/web/api/screenorientation/index.md
{{APIRef("Screen Orientation API")}}
The ScreenOrientation interface of the Screen Orientation API provides information about the current orientation of the document.
A ScreenOrientation instance object can be retrieved using the {{domxref("screen.orientation")}} property.
{{InheritanceDiagram}}
portrait-primary, portrait-secondary, landscape-primary, or landscape-secondary.Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of this interface.
In the following example, we listen for an orientation {{DOMxRef("ScreenOrientation.change_event", "change")}} event and log the new {{DOMxRef("ScreenOrientation.type", "screen orientation type", "", "nocode")}} and {{DOMxRef("ScreenOrientation.angle", "angle", "", "nocode")}}.
screen.orientation.addEventListener("change", (event) => {
const type = event.target.type;
const angle = event.target.angle;
console.log(`ScreenOrientation change: ${type}, ${angle} degrees.`);
});
{{Specifications}}
{{Compat}}