Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

cannot match tea.KeySpace #264

Closed
tgirod opened this issue Mar 22, 2022 · 2 comments
Closed

cannot match tea.KeySpace #264

tgirod opened this issue Mar 22, 2022 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@tgirod
Copy link

tgirod commented Mar 22, 2022

I think (correct me if I'm wrong) it is not possible to match any event to tea.KeySpace.

@meowgorithm
Copy link
Member

Hi! You actually just match on a literal space:

// It's usually simplest to just use the Stringer interface
switch msg.String() {
case " ":
    // It's a space!
}

// The super verbose way
if msg.Type == tea.KeyRunes && string(msg.Runes) == " " {
   // It's a space!
}

@tgirod
Copy link
Author

tgirod commented Mar 24, 2022

Thanks, I figured that part by myself! ;)

What I meant is, pressing [space] in bubbletea will produce a Key{Type: KeyRunes} event, but no keystroke will ever produce a Key{Type: KeySpace}, and I find it misleading.

In my first program I wanted [space] to trigger a special behaviour, so naturally I went for something like this:

switch msg.Type {
case tea.KeySpace:
    // triggers something special
case tea.KeyRunes:
    // append to the model's state
}

... and it took me some time to realize that this won't match the space key.

@bashbunni bashbunni added the question Further information is requested label Apr 1, 2022
@bashbunni bashbunni self-assigned this Apr 1, 2022
@charmbracelet charmbracelet locked and limited conversation to collaborators Apr 11, 2022
@bashbunni bashbunni converted this issue into discussion #288 Apr 11, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants