stib
stib

Reputation: 3512

disabling left and right arrows on a website that uses them for navigation (duckDuckGo)

Duckduckgo.com has keyboard navigation that lets you hit the left and right arrows to go from web results, to image results, news and maps. All good, except when I'm browsing using my wacom tablet. If I scroll with the tablet and I accidentally scroll just a little bit left or right it sends left and right arrow keypresses, which means that the search results are swapping between all the modes. It makes DDG kinda unuseable with a tablet.

I wrote a tampermonkey script to disable the keydown events, but while it disables the left and right arrows in the search box text input, it doesn't prevent the dreaded left and right navigation.

// ==UserScript==
// @name         disable left-right arrows in DDG
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  the left and right scrolling in DDG is annoying when you're using a tablet
// @author       stib
// @match        https://duckduckgo.com/*
// @grant        none
// ==/UserScript==
(function() {
    'use strict';
    document.onkeydown=function(keydn){
        if ((keydn.key === "ArrowRight") || (keydn.key === "ArrowLeft")) {
            keydn.cancelBubble = true;
            keydn.preventDefault();
            return false;
        }
    }
})();

Upvotes: 0

Views: 515

Answers (0)

Related Questions