Skip to content

KcdMp.env.screen

The size of the page and its display’s pixel ratio.

Read it when you need it: every read gives a fresh object with the size at that moment, so a page that adapts to its size reads it again on a resize event.

KcdMp.env.screen

KcdMpScreen

The size of the page and of the display it is drawn on.

Field Type
w number the page’s width in CSS pixels
h number the page’s height in CSS pixels
scale number the display’s pixel ratio (2 on a display that draws two device pixels per CSS pixel)
window.addEventListener("resize", () => {
const { w, h } = KcdMp.env.screen;
document.body.classList.toggle("narrow", w < 900 || h < 500);
});

KcdMp.env · the The page group of the index