Search code examples
javascriptcssscrollscrollbararrows

Scrollbar but not scrolling on arrows


I want to keep my scroll bar and off its scrolling only on Arrow..

I tried to insert it to div overflow: scroll and then to second div overflow: hidden inside first..
but it doesn't work

*Any idea? *


Solution

  • If you want to prevent scrolling with arrows,

    // add keyboard events
                        $( document ).keydown( function(e) {
                            var keyCode = e.keyCode || e.which,
                                arrow = {
                                    left : 37,
                                    up : 38,
                                    right : 39,
                                    down : 40,
                                    escape : 27
                                };
    
                            switch (keyCode) {
                                case arrow.up:
                                    e.preventDefault();
                                    }
                               case arrow.down:
                                    e.preventDefault();
                                    }
                                    break;