Keyboard-navigation problem

Keyboard-navigation problem

Hello! Hope you're fine! First I will excuse for my bad english. Have some problem with a keyboard-scroll-script. I don't know what I'm doing wrong. I want it to work like this (link1), press "UP" and "DOWN"-arrows to test. But right now it doesn't work here (link2). I have made a script who set the height and width to 100% of the screen. Then I have a script which will listen for keyboard-press of "UP" and "DOWN" key, and then scroll from section, to section (class: keyboardscroll). But it doesn't work on the second link (link2). Someone who know why? Or can help me fix this working? If I forgot to explain something, please tell me!
Thanks for all kind of help!

Script for resizing to 100% sections:

  1. $(document).ready(function() {

  2. $(window).resize(function() {

  3. Resize();

  4. });

  5. var Resize = function() {

  6. var windowHeight = $(window).height(),
  7. windowWidth = $(window).width();
  8. $("section").css("width", windowWidth);
  9. $("section").css("height", windowHeight);

  10. }

  11. $(window).resize(function() {

  12. Resize();

  13. });

  14. setTimeout(Resize, 20);
  15. Scrolling();

  16. });
Script for keyboard-scroll:

  1. $(window).load(function(){
  2. $(function() {
  3.     var boxLefts = [];
  4.     $('div.keyboardscroll').each(function(i, el){
  5.         boxLefts.push(this.offsetTop);
  6.     });
  7.     
  8.     $(document).keydown(function(e) {
  9.         var dir = false,
  10.             targetTop = -1;
  11.         
  12.         switch (e.keyCode) {
  13.         case 38:
  14.             dir = -1;
  15.             break;                
  16.         case 40:
  17.             dir = 1;
  18.             break;
  19.         default:
  20.             break;
  21.         }

  22.         if (dir) {
  23.             e.preventDefault();
  24.             winDown = window.scrollY;
  25.             $.each(boxLefts, function(i, v){
  26.                 if ((dir == 1 && winDown < v && targetTop < 0) ||
  27.                     (dir == -1 && winDown > v)) {
  28.                     targetTop = v;
  29.                 }
  30.             });
  31.             if (targetTop >= 0) {
  32.                 $('html, body').animate({scrollTop: targetTop}, 200);
  33.             }
  34.         }
  35.     });
  36. });
  37. });

Have a nice day!

Sincerly,
J