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

Expose an interface to check if a key is being pressed #3444

Closed
miversen33 opened this issue Apr 4, 2023 · 3 comments
Closed

Expose an interface to check if a key is being pressed #3444

miversen33 opened this issue Apr 4, 2023 · 3 comments
Labels
enhancement New feature or request fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. keyboard Keyboard mapping/handling

Comments

@miversen33
Copy link
Sponsor

Is your feature request related to a problem? Please describe.
RE: Discussion #3441
I am looking for a way to indicate in the statusbar that the Caps Lock is enabled from lua. As a tangential request, it may make sense to expose a way to check if any key is currently being "activated" (pressed).

Describe the solution you'd like
There are 2 trains of thought here.

  1. A function that exists (likely on window but potentially on the global wezterm object?). Something akin to
require("wezterm").is_key_pressed(SOME_KEY)
-- Or on the window object
window:is_key_pressed(SOME_KEY)

Its worth calling out that this kind of feature, while I think it would be helpful, ultimately wouldn't resolve the issue at hand as CAPS LOCK is a special stateful key (IE, CAPS LOCK is either enabled or disabled, similar to how INSERT is either enabled or disabled). Because of this, this first request is a want that could potentially be seen as its own separate work effort (and also "No" is of course acceptable).

  1. A function that exists (likely on window) to check if CAPS LOCK is currently active (much more achievable IMO).
window:caps_is_active()

This would function exactly like window:leader_is_active() and I imagine under the hood the logic would be nearly the same (though leader has a timeout and caps lock generally doesn't by default).

Describe alternatives you've considered
Its possible to wrap the key in a keytable event and track the state of capslock via that but that seems really ick and not at all preferred.

Additional context
Thank you for this project :) I don't know rust in any meaningful way so I unfortunately can't really contribute at this time. Thus all I have are suggestions from an end user perspective :)

@miversen33 miversen33 added the enhancement New feature or request label Apr 4, 2023
@wez wez added the keyboard Keyboard mapping/handling label Apr 17, 2023
@wez
Copy link
Owner

wez commented Apr 17, 2023

window:keyboard_modifiers() is available now in main.

You'll need f3ee5e5 to have your update-status event handler trigger as modifiers are changed on x11 and (probably: I haven't tested it to see if actually works!) wayland.

@wez wez added the fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. label May 29, 2023
@eugenesvk
Copy link
Contributor

If you alt-tab to a different window, does the status stick for you when you switch back until you press or release a key (seems to stick here on a Mac), if so, then maybe if could check on regaining focus that no keys are held and reset the status?

@wez wez closed this as completed Jul 12, 2023
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. keyboard Keyboard mapping/handling
Projects
None yet
Development

No branches or pull requests

3 participants