Q:

Detecting if Home/End Keys is pressed in JS

I am trying to implement an infinite scroll in JS, I am using $(window).scroll() to detect the scroll position, every thing is working fine, I just have one issue I want the url to change if the user clicks the 'Home' key and then change again if the user press the 'End' key.
So when Home is clicked the scroll position will be move to the top and when End is clicked the scroll position will be moved to the bottom.
My Question is, how do you detect these behaviors (pressing Home/End)? 
Youssef

A:

KeyCode is 35 for END 36 for HOME!
  function myKeyPress(e){

        var keynum;

        if(window.event){ // IE                 
            keynum = e.keyCode;
        }else
            if(e.which){ // Netscape/Firefox/Opera                  
                keynum = e.which;
             }
        alert(String.fromCharCode(keynum));
    }

A:

Home, PageUp, PageDown, End and some other keys are only triggered by onkeydown, not onkeypress see this post

