Inconsistent key inputs between terminal apps on Mac (Terminal and iTerm2) #291
-
I'm confident they may be having separate underlying implementations on how key inputs are handled but I don't know how to [think or] approach it as a TUI app. For my particular case, I have set up a keybind like this: func NewViewport() Model {
tabs := []string{"Headers (q)", "Request Body (w)", "Response (e)"}
keybinds := keymap{
nextTab: key.NewBinding(key.WithKeys("alt+f"), key.WithHelp("⌥→", "Next tab")),
previousTab: key.NewBinding(key.WithKeys("alt+b"), key.WithHelp("⌥←", "Prev tab")),
}
return Model{
tabs: tabs,
keybinds: keybinds,
}
} So
"Key is" is my logging prefix. This effectively allows the switch case to not match my binding. However on iTerm, I get What's the general approach for such cases apart from considering alternate keybinds? As a secondary request, is there a list/file of all the keys in their string representation for reference for bubbletea? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi! So terminals don't have a notion of the option key. On macOS Terminal and iTerm2 you need to tick a box in settings to have option send On a personal note, when I'm on a Mac I setup Kitty so that I my left option key is bound to alt/meta while the right option remains bound to option so I still have access to the system-wide, option-based keybindings—particularly those that let me enter special characters. Separately, per your question about string representations for keys, there's no official reference for string representations of keys at the moment, but you can get an idea what they look like below. Not listed are basic latin characters like Lines 225 to 293 in 515ef02 |
Beta Was this translation helpful? Give feedback.
-
Thanks @meowgorithm. This answer is helpful. |
Beta Was this translation helpful? Give feedback.
Hi! So terminals don't have a notion of the option key. On macOS Terminal and iTerm2 you need to tick a box in settings to have option send
alt
(which is often calledmeta
). What it sounds like is happening is that one of your terminals is sendingalt
/meta
from the option key and the other is not.On a personal note, when I'm on a Mac I setup Kitty so that I my left option key is bound to alt/meta while the right option remains bound to option so I still have access to the system-wide, option-based keybindings—particularly those that let me enter special characters.
Separately, per your question about string representations for keys, there's no official reference for string representatio…