wshanks / tbkeys

Custom keybindings for Thunderbird
Other
200 stars 14 forks source link

multimedia / special keys #93

Open avg-I opened 3 years ago

avg-I commented 3 years ago

This is more of a question than an issue (at least for now). How to configure shortcuts for multimedia / special keys? I would like to set a custom action for XF86Forward (using KDE / X).

While here, the same question for extended mouse buttons.

Thank you!

wshanks commented 3 years ago

This is not possible at the moment with tbkeys. mousetrap (which tbkeys uses for managing the keybindings) has support for binding to arbitrary keycodes: https://craig.is/killing/mice#api.addKeycodes. However, some work is needed to expose this feature to the tbkeys settings. I think these keys are not built in because they might be problematic (map to different keycodes for different computers / keyboards so hard to add general support for).

Maybe the easiest way to support these keys is to add another section in the preferences where the user can specify the key code to key name mapping as needed by addKeycodes and leave it to the user to figure out the right keycodes to map.

mikegrogan commented 4 weeks ago

I was wondering about mapping the insert key on the keyboard to flagging email. I guess this answers my question that it's not available. I have the same shortcut in another email program, so it would have been really handy.

morat523035 commented 4 weeks ago

You could use the userChromeJS addon to handle the XF86Back and XF86Forward multimedia keys.

* <profile folder>\chrome\userChrome.js

/* Thunderbird userChrome.js */

(function () {
  if (location == "chrome://messenger/content/messenger.xhtml") {
    setTimeout(function () {
      try {
        window.addEventListener("AppCommand", function (aEvent) {
          switch(aEvent.command) {
            case "Back":
              aEvent.stopImmediatePropagation();
              alert("test back");
              break;
            case "Forward":
              aEvent.stopImmediatePropagation();
              alert("test forward");
              break;
          }
        }, true);
      } catch (aError) {
        Components.utils.reportError(aError);
      }
    }, 3000);
  }
})();

I didn't test the code since I'm not using a multimedia keyboard.

userChromeJS by jikamens http://addons.thunderbird.net/thunderbird/addon/986610

Similar thread http://forums.mozillazine.org/viewtopic.php?t=2661059

morat523035 commented 4 weeks ago

I guess you could use the userChromeJS addon to handle the insert keypress event.

* <profile folder>\chrome\userChrome.js

/* Thunderbird userChrome.js */

(function () {
  if (location == "chrome://messenger/content/messenger.xhtml") {
    setTimeout(function () {
      try {
        window.addEventListener("keypress", function (aEvent) {
          if (aEvent.keyCode == KeyEvent.DOM_VK_INSERT) {
            aEvent.stopImmediatePropagation();
            alert("test insert");
          }
        }, true);
      } catch (aError) {
        Components.utils.reportError(aError);
      }
    }, 3000);
  }
})();

I tested the code using the error console.

userChromeJS by jikamens http://addons.thunderbird.net/thunderbird/addon/986610

I can use the insert key to toggle between insert mode and overwrite mode in the Notepad++ app.

I don't believe the Thunderbird app has an overwrite mode so I guess the insert key is useless.