Landscape mode in a view

I’ve tried with events, but that doesn’t work.

document.addEventListener('onorientationchange', function() 
   {...}
);

I know how to get the orientation of the screen, but i didn’t find out how to detect when the orientation changes.