Skip to content

Feature request / question: Get modifier keys on keyboard event #5318

Closed

Description

@novak-services

To fully support the keyboard in my application, I would need to be able to get the current state of the modifier keys (shift,control,meta).

The key event does not provide that. For example if I press the return key, I see no difference if I press return with or without space key.

Interestingly Mouse events seem to support it, but I do not want to wait for a mouse event to fire -- the interactions should be triggered from the keyboard alone.

It also could be a separate function to get that state, but it really would make my application possible, since I would need to find another way of implementing it, if it is not possible in textual.

Is there a way to do that already (I scanned the documentation and FAQ but found nothing yet)? If not, would it be possible to integrate such a functionality in reasonable time?

Could that be available with "Extended keys" #3411 ? That would also be a possibility for me, to use such a terminal, but I saw no possibility to integrate it into the current Key event structure, so I did not try a terminal with that support yet.

Any response would be appreciated.

Activity

  1. github-actions commented on Dec 2, 2024

    @github-actions

    Thank you for your issue. Give us a little time to review it.

    PS. You might want to check the FAQ if you haven't done so already.

    This is an automated reply, generated by FAQtory

  2. willmcgugan commented on Dec 2, 2024

    @willmcgugan
    Member

    Modifiers are encoded in the key name, but you will need a terminal that supports the extended key protocol to use them.

    Screenshot 2024-12-02 at 16 38 44
  3. novak-services commented on Dec 4, 2024

    @novak-services
    Author

    Thank you VERY MUCH.

    That was really helpful. I tried it with WezTerm and works like a charm and I get now all information my Application needs.

    I am getting more and more into Textual and it is real great.

  4. github-actions commented on Dec 4, 2024

    @github-actions

    Don't forget to star the repository!

    Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions