15

I'm especially interested in disabling "T" button.

  • What page are you on for T? – Eight Days of Malaise Oct 29 '13 at 20:22
  • @EightDaysofMalaise At least on every "repository" page. For example here: github.com/qbittorrent/qBittorrent . I haven't noticed before, it's shortcut for "file finder" – janot Oct 30 '13 at 10:30
  • I use search-as-you-type to find things in my editors and on github pages, it's really annoying when it jumps me off the page i'm on and onto the "find a file" screen because i pressed 't'. – Conan Jul 4 '14 at 9:23
  • @TomWoodward thx, looks like it will work everywhere – janot Feb 12 '16 at 4:22
2

Basically copying answer from superuser.com linked by Tom Woodward in comments. I've only changed keycode and url.

It's Greasemonkey script which disables "T" shortcut. Supported by major browsers (extension like Greasemonkey for Firefox/Tampermonkey for Chrome may be needed/useful).

// Your code here...

// ==UserScript==
// @name           Disable keyboard shortcuts
// @description    Stop websites from highjacking keyboard shortcuts
//
// @run-at         document-start
// @include        *github.com*
// @grant          none
// ==/UserScript==

keycodes = [84] // Keycode for 'T', add more keycodes to disable other key captures

document.addEventListener('keydown', function(e) {
//    alert(e.keyCode); //uncomment to find out the keycode for any given key
    if (keycodes.indexOf(e.keyCode) != -1)
    {
        e.cancelBubble = true;
        e.stopImmediatePropagation();
    }
    return false;
});
  • Unfortunately, this solution doesn't work in most mobile browsers. Of course, for most mobile phones, overriden keyboard shortcuts is not an issue, but it is if you have a modern BlackBerry with a keyboard (Classic, in my case) and you've gotten used to pressing "T" to go to the top of the page... – user103148 Feb 16 '17 at 21:55
  • @FighterJet I haven't checked this particular script, but you may probably convert it to bookmarklet, so it would work even on your BlackBerry's default browser. Process is pretty straightworward, but there are some limitations – janot Feb 17 '17 at 1:55
  • While that will probably work, it would be rather inconvenient to do every page load. Better to just remember that GitHub steals my T key and scroll to top manually or by tapping the title bar. – user103148 Feb 17 '17 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.