Fix duplicate bit masks for caps lock and num lock #863
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm using the Kitty terminal emulator with crossterm's raw mode,
DISAMBIGUATE_ESCAPE_CODES
andREPORT_ALL_KEYS_AS_ESCAPE_CODES
. I noticed that caps lock was always being reported as active viaevent.state.contains(KeyEventState::CAPS_LOCK)
, even when toggling the key many times and restarting my program. Looking into crossterm's source, I found what looks like a simple copy/paste bug:CAPS_LOCK
andNUM_LOCK
both use the bit mask0b000_1000
.0b0000_0001
is used but0b0000_0010
and0b0000_0100
aren't, so I went ahead and assigned those sequentially instead. With this change, caps lock is being detected as expected. I haven't tested numlock (my current keyboard doesn't have it clearly labeled) but I expect this can only help.