[GH-ISSUE #1003] Feature Request: Support hjkl navigation in TUI modals. #724

Closed
opened 2026-03-04 01:07:17 +03:00 by kerem · 4 comments
Owner

Originally created by @F1bonacc1 on GitHub (Jun 28, 2024).
Original GitHub issue: https://github.com/rivo/tview/issues/1003

Feature Request

Allow using hjkl binding in modal dialogs as an alternative to arrow navigation.

Use Case:

Vimmers wanting to vim everywhere

Original issue: https://github.com/F1bonacc1/process-compose/issues/193

Originally created by @F1bonacc1 on GitHub (Jun 28, 2024). Original GitHub issue: https://github.com/rivo/tview/issues/1003 ## Feature Request Allow using `hjkl` binding in modal dialogs as an alternative to arrow navigation. ## Use Case: Vimmers wanting to vim everywhere Original issue: https://github.com/F1bonacc1/process-compose/issues/193
kerem closed this issue 2026-03-04 01:07:18 +03:00
Author
Owner

@kivattt commented on GitHub (Jun 29, 2024):

You can add hjkl navigation by using SetInputCapture on the modal

This is what I've done before to add it to modals: github.com/kivattt/fen@83643815f7/main.go (L271)

<!-- gh-comment-id:2198144178 --> @kivattt commented on GitHub (Jun 29, 2024): You can add `hjkl` navigation by using [SetInputCapture](https://pkg.go.dev/github.com/rivo/tview#Box.SetInputCapture) on the modal This is what I've done before to add it to modals: https://github.com/kivattt/fen/blob/83643815f7e03aaf4c700e8342edfe20aeb95319/main.go#L271
Author
Owner

@F1bonacc1 commented on GitHub (Jun 29, 2024):

Thanks @kivattt,
That will work for sure. Wouldn't it be better to make it consistent with other widgets in which hjkl is already supported?

<!-- gh-comment-id:2198185901 --> @F1bonacc1 commented on GitHub (Jun 29, 2024): Thanks @kivattt, That will work for sure. Wouldn't it be better to make it consistent with other widgets in which `hjkl` is already supported?
Author
Owner

@rivo commented on GitHub (Jul 8, 2024):

To be honest, I think it was a mistake to add vim-like navigation to tview. At first, I did it because there are many vim users out there (myself included) and most widgets in the initial version of this package were read-only so it didn't hurt to add these keybinds. However, this doesn't work with widgets like InputField or the later introduced TextArea. At least not without adding modes. (And that's definitely something that's not going to be added to tview.) The bash-like / readline type of keybinds which use Ctrl lend themselves better to the widgets offered in this library, as they don't interfere with normal text input.

I know we're now left with a somewhat inconsistent state of affairs because of the backwards compatibility promise. I'm not going to remove these keybinds but I probably won't add new ones. As @kivattt mentioned, people can always customize their widgets to their liking.

I'm working on an API which will make it easier to add these kind of changes to widgets. Then you might even be able to include a third-party package that will enable vim-like navigation across the board.

<!-- gh-comment-id:2215330612 --> @rivo commented on GitHub (Jul 8, 2024): To be honest, I think it was a mistake to add vim-like navigation to `tview`. At first, I did it because there are many vim users out there (myself included) and most widgets in the initial version of this package were read-only so it didn't hurt to add these keybinds. However, this doesn't work with widgets like `InputField` or the later introduced `TextArea`. At least not without adding modes. (And that's definitely something that's not going to be added to `tview`.) The bash-like / readline type of keybinds which use <kbd>Ctrl</kbd> lend themselves better to the widgets offered in this library, as they don't interfere with normal text input. I know we're now left with a somewhat inconsistent state of affairs because of the backwards compatibility promise. I'm not going to remove these keybinds but I probably won't add new ones. As @kivattt mentioned, people can always customize their widgets to their liking. I'm working on an API which will make it easier to add these kind of changes to widgets. Then you might even be able to include a third-party package that will enable vim-like navigation across the board.
Author
Owner

@F1bonacc1 commented on GitHub (Jul 8, 2024):

Thank you @rivo for the detailed answer.
In this case, I will use @kivattt's suggestion.
Thanks again for this amazing library!

<!-- gh-comment-id:2215350687 --> @F1bonacc1 commented on GitHub (Jul 8, 2024): Thank you @rivo for the detailed answer. In this case, I will use @kivattt's suggestion. Thanks again for this amazing library!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#724
No description provided.