detect scroll javascript

JavaScript
window.onscroll = function (e) {  
// called when the window is scrolled.  
} 

Source

Also in JavaScript: