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

ctrl+<number> not captured #1207

Open
jonas-grgt opened this issue Oct 27, 2024 · 3 comments
Open

ctrl+<number> not captured #1207

jonas-grgt opened this issue Oct 27, 2024 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@jonas-grgt
Copy link

jonas-grgt commented Oct 27, 2024

When pressing ctrl+ only the number is received in the Update method.

To Reproduce

func (t *Model) Update(msg tea.Msg) {
	switch msg := msg.(type) {
	case tea.KeyMsg:
		if s := msg.String(); s == "ctrl+1" {

When pressing Ctrl+1 and evaluating msg.String() it returns "1"

Expected behavior
When pressing Ctrl+1 and evaluating msg.String() it returns "ctrl+1"

@semihbkgr
Copy link
Contributor

To my understanding, the behavior you're seeing with Ctrl+1 is because the terminal only sends the character 1 without a distinct representation for the Ctrl modifier, as numeric key combinations do not generate unique key events like some control characters do.

@jonas-grgt
Copy link
Author

@semihbkgr thanks for point this out I wasn't aware of this. So basically all Ctrl / Alt / Meta + number combinations can't be used?

@bashbunni
Copy link
Member

Hey @jonas-grgt there is support for extended key combinations in v2 which is currently in alpha - we're at v2-alpha.2 now. You can also try again with a terminal emulator that supports the Kitty Keyboard Protocol.

Please let me know if these solutions end up working for you!

@bashbunni bashbunni added the question Further information is requested label Nov 28, 2024
@bashbunni bashbunni self-assigned this Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants