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

Add `KeyString`?

Open madsmtm opened this issue 11 months ago • 4 comments

Should we add a type KeyString that could implement the restrictions in the spec?

This would allow Key::Character to be fully restricted in the set of values it can have, to avoid e.g. Key::Character("Shift") or Key::Character("\t").

madsmtm avatar Feb 13 '25 19:02 madsmtm

Just noting it down as an idea, not sure I like it myself.

madsmtm avatar Feb 13 '25 19:02 madsmtm

A key string is a string containing a 0 or 1 non-control characters ("base" characters) followed by 0 or more combining characters. The string MUST be in Normalized Form C (NFC) as described in [UAX15].

This basically requires the crate to depend on the Unicode database to check which classes characters belong to and to construct the NFC. I don't this is needed as the key string is usually provided by the operating system (or browser) and hopefully follows these rules.

pyfisch avatar Mar 09 '25 10:03 pyfisch