Pan Tilt Hat Web Interface KeyDown Loop

Hello, I have the Pan Tilt Hat web server example loaded but I am unable to keep the unit moving while holding down an arrow key. It moves briefly then stops. I looked into the code and could not figure out what the problem is since the keydown should be looping until keyup. How can I edit this base code to loop the KeyDown?

$(function(){
                $(window).on('keydown',function(e){
                    clearInterval(interval);
                    switch(e.keyCode){
                        case 38: // Arrow Up
                            current_direction = 'tilt';
                            current_angle = 1;
                            interval = setInterval(pantilt,pantilt_speed);
                            break;
                        case 40: // Arrow Down
                            current_direction = 'tilt';
                            current_angle = -1;
                            interval = setInterval(pantilt,pantilt_speed);
                            break;
                        case 37: // Arrow Left
                            current_direction = 'pan';
                            current_angle = 1;
                            interval = setInterval(pantilt,pantilt_speed);
                            break;
                        case 39: // Arrow Right
                            current_direction = 'pan';
                            current_angle = -1;
                            interval = setInterval(pantilt,pantilt_speed);
                            break;
                    }
                });
                $(window).on('keyup',function(e){clearInterval(interval)});

I far from being any kind of expert on this stuff but my best guess is its the break command thats doing it.
“maybe” this will help.