pc-keyboard icon indicating copy to clipboard operation
pc-keyboard copied to clipboard

Inconsistent decoding

Open katietheqt-old opened this issue 6 years ago • 3 comments

Your crate decodes some keys into DecodedKey::RawKey objects. The enum that you provide containing keys has a Backspace variant, but, using QEmu as my example, a backspace is decoded into unicode U+0008, and as a DecodedKey::Unicode.

katietheqt-old avatar Dec 29 '18 17:12 katietheqt-old

That's because I understood 0x08 to be the ASCII value for Backspace, like 0x09 is the ASCII value for Tab. I only used DecodedKey::RawKey when there wasn't a clear mapping to an ASCII (or Unicode) value (e.g. there's no ASCII or even Unicode value corresponding to the Windows key). If you'd rather have raw key events (i.e. the KeyCode enum you mention that includes KeyCode::Backspace, plus an indication of whether the key was pressed or released), you can avoid calling process_keyevent and handle the key events yourself.

thejpster avatar Jan 02 '19 22:01 thejpster

Then can we remove the Backspace variant of the enum, as it is not used, and only use ASCII Backspace

katietheqt-old avatar Jan 03 '19 17:01 katietheqt-old

It is used if you take KeyEvents and don't decode them.

I can see your point though. I could create a new enum called UndecodableKeys or something. It would include Home, PageUp, etc, but not A, +, or Backspace. You can then match exhaustively without overlaps.

thejpster avatar Jan 04 '19 07:01 thejpster