crossterm
crossterm copied to clipboard
Fix duplicate bit masks for caps lock and num lock
I'm using the Kitty terminal emulator with crossterm's raw mode, DISAMBIGUATE_ESCAPE_CODES and REPORT_ALL_KEYS_AS_ESCAPE_CODES. I noticed that caps lock was always being reported as active via event.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 and NUM_LOCK both use the bit mask 0b000_1000. 0b0000_0001 is used but 0b0000_0010 and 0b0000_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.
Yeah -- just a change log entry will be sufficient and we can maintain semantic versioning.
I also just ran in to this, I can't imagine a case where this was intended and would actually be hitting someone as-it-is-written, possibly though it may be?