Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent thread expansion with j/k navigation keys #126

Open
labrnth opened this issue Feb 7, 2023 · 4 comments
Open

Prevent thread expansion with j/k navigation keys #126

labrnth opened this issue Feb 7, 2023 · 4 comments

Comments

@labrnth
Copy link

labrnth commented Feb 7, 2023

Good morning,

I'm wondering if there is a way to prevent email threads from expanding when using j/k navigation keys. I'd like to be able to map h/l keys to expand and collapse threads like (like using Vim). With that said I'm very grateful for this add-on.

Cheers,
-Chris

@morat523035
Copy link

morat523035 commented Feb 8, 2023

Use the unset binding to unbind built-in key bindings.

Command syntax
http://github.com/wshanks/tbkeys#command-syntax

Do you want the command for the "Ignore Thread" menu item?

i.e. Menu Bar > Message > Ignore Thread

Toggle "Ignore Thread" menu item:

window.goDoCommand('cmd_killThread');

Check "Ignore Thread" menu item:

if (!window.gFolderDisplay.selectedMessageThreadIgnored) window.goDoCommand('cmd_killThread');

Uncheck "Ignore Thread" menu item:

if (window.gFolderDisplay.selectedMessageThreadIgnored) window.goDoCommand('cmd_killThread');

@labrnth
Copy link
Author

labrnth commented Feb 8, 2023

@morat523035 thanks for you response. I'd like to be able to continue suing J and K to navigate up and down the message list but when I come to a thread (thats collapsed) I dont want the thread to expand as I go up/down the list. I would like to use the keys H and L to expand or collapse the thread when needed. If that makes sense.

Kind of how the arrow keys currently function. I literally would like to bind J and K to the up/down arrow keys and H and L to the left/right arrow keys. Is that possible?

@morat523035
Copy link

morat523035 commented Feb 8, 2023

You want to synthesize a keypress event on the active window. The nsIDOMWindowUtils.sendKeyEvent method doesn't work anymore. Try the nsIDOMWindowUtils.sendNativeKeyEvent method.

(function () {
  var KEYBOARD_LAYOUT_EN_US = {name: 'US', Mac: 0, Win: 0x00000409, hasAltGrOnWin: false};
  var WIN_VK_DOWN = 0xe0500028;
  window.windowUtils.sendNativeKeyEvent(KEYBOARD_LAYOUT_EN_US, WIN_VK_DOWN, 0, '', '');
})();

Reference
http://searchfox.org/mozilla-esr102/search?q=KEYBOARD_LAYOUT_EN_US
http://searchfox.org/mozilla-esr102/search?q=WIN_VK_DOWN
http://searchfox.org/mozilla-esr102/search?q=sendNativeKeyEvent

Another example
http://github.com/wshanks/tbkeys/issues/125#issuecomment-1423402126

@polychronakis
Copy link

polychronakis commented Jun 13, 2024

Thanks a ton for this helpful comment. Here is the full set of hjkl mappings in case anyone else needs to do this:

"h": "(function () {var KEYBOARD_LAYOUT_EN_US = {name: 'US', Mac: 0, Win: 0x00000409, hasAltGrOnWin: false}; var WIN_VK_LEFT = 0xe04b0025; window.windowUtils.sendNativeKeyEvent(KEYBOARD_LAYOUT_EN_US, WIN_VK_LEFT, 0, '', '');})();",
"j": "(function () {var KEYBOARD_LAYOUT_EN_US = {name: 'US', Mac: 0, Win: 0x00000409, hasAltGrOnWin: false}; var WIN_VK_DOWN = 0xe0500028; window.windowUtils.sendNativeKeyEvent(KEYBOARD_LAYOUT_EN_US, WIN_VK_DOWN, 0, '', '');})();",
"k": "(function () {var KEYBOARD_LAYOUT_EN_US = {name: 'US', Mac: 0, Win: 0x00000409, hasAltGrOnWin: false}; var WIN_VK_UP = 0xe0480026; window.windowUtils.sendNativeKeyEvent(KEYBOARD_LAYOUT_EN_US, WIN_VK_UP, 0, '', '');})();",
"l": "(function () {var KEYBOARD_LAYOUT_EN_US = {name: 'US', Mac: 0, Win: 0x00000409, hasAltGrOnWin: false}; var WIN_VK_RIGHT = 0xe04d0027; window.windowUtils.sendNativeKeyEvent(KEYBOARD_LAYOUT_EN_US, WIN_VK_RIGHT, 0, '', '');})();",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants