Recognizing letters in is a surprisingly non-trivial task. As of right now, RegExp property escapes are only available in the fairly recent Chrome 64. The alternative is compiling a huge (4 KB) regular expression from Unicode data.

I think that I'll use the function below - a letter is something that is modified by toUpperCase() or toLowerCase(). This excludes some more exotic letter variants, and it just won't work on scripts like Hebrew or Arabic, but it should do for my use case for now.

Now I only need some basic heuristic for recognizing vowels and my code should be able to make a usable access key selection automatically.


Actually, combining Unicode property escapes with the heuristic above as fallback is easy enough. So in current Chrome my isLetter() function will use the more correct approach while in Firefox it will be the simple but not quite correct fallback code.

Sign in to participate in the conversation
Infosec Exchange

A Mastodon instance for info/cyber security-minded people.