The deadkeys do not seem work for accented vowels

Hello, I am new to the Keyman developer, so apologies on any oversight ; I’ve been trying to develop a keyboard where the quotes, double quotes and the semicolon act as dead keys; I followed the tutorial on the Keyman Developer Guide website and the keyboard compiled successfully as well, but upon testing the deadkeys for the vowels are not working while the ones for the consonants are working just fine. Here’s the bit of code I’ve written:

group(main) using keys
+ U+0071 > U+0259
+ U+0077 > U+0254
+ U+0061 > U+0061
+ U+0062 > U+0062
+ U+0063 > U+0063
+ U+0064 > U+0064
+ U+0065 > U+0065
+ U+0066 > U+0066
+ U+0067 > U+0067
+ U+0068 > U+0068
+ U+0069 > U+0069
+ U+006A > U+006A
+ U+006B > U+006B
+ U+006C > U+006C
+ U+006D > U+006D
+ U+006E > U+006E
+ U+006F > U+006F
+ U+0070 > U+0070
+ U+0072 > U+0072
+ U+0073 > U+0073
+ U+0074 > U+0074
+ U+0075 > U+0075
+ U+0076 > U+0076
+ U+0078 > U+0078
+ U+0079 > U+0079
+ U+007A > U+007A

c storing vowels
store( plainvowels ) "aeiouəɔAEIOUƏƆ" 
store( acutevowels ) "áéíóúə́ɔ́ÁÉÍÓÚƏ́Ɔ́" 
store( tildevowels ) "ãẽĩõũə̃ɔ̃ÃẼĨÕŨƏ̃Ɔ̃"

c storing consonants
store( plainconsonants ) "rtsdgjlzcnRTSDGJLZCN"
store( caronconsonants ) "řťšďǧǰľžčňŘŤŠĎǦJ̌ĽŽČŇ"

c Output deadkeys only for the accent keys pressed
+ "'" > dk(quote)     c Quote for acute accent
+ '"' > dk(dbquote)   c Double-quote for tilde
+ ";" > dk(semicol)   c semicolon for caron

c Rules for accented characters
dk(quote)   + any( plainvowels ) > index( acutevowels, 2 )
dk(dbquote) + any( plainvowels ) > index( tildevowels, 2 )
dk(semicol) + any( plainconsonants ) > index( caronconsonants, 2 )

c rules for n
dk(semicol) + "n" > U+00F1
dk(semicol) + "N" > U+00D1

"<" + "<" > U+00AB        c Angled quotes
">" + ">" > U+00BB

c Rules for the accent character itself (type it twice)
dk(quote)   + "'" > "'"   c Quote
dk(semicol) + ";" > ";"   c semicolon
dk(dbquote) + '"' > '"'   c Double-quote

I’ve tried to figure out what might be causing the deadkeys to not work, but to no success. Some help regarding this would be much appreciated.

I think your rules look okay, although I didn’t test them.

Are you testing the keyboard in Keyman developer or are you testing in Word? If you are using Word, it’s quite possible that Word is turning the quotes into smart quotes before these rules ever fire. If that’s the case, you need to turn off smart quotes in Word. File / Options / Proofing / AutoCorrect / AutoFormat and then uncheck “Straight quotes” with “smart quotes”.

Of course, other applications may do this also, and I wouldn’t know where those settings are. You may wish to consider a different deadkey, but I know the position of this one is convenient to the user.

1 Like

This was a tricky one. But I think it is failing because you entered your acutevowels string with ordinary vowels followed by the combining diacritic. This throws off the index command. When you press the deadkey then “a” you get the first character from acutevowels, which is an ‘a’. If you press deadkey then “e” you get the second character from acutevowels, which is the combining acute mark.

So if you really want the output to be decomposed characters, you cannot use the index command.
You can do this letter by letter with code like:
dk(quote) + ‘a’ > ‘a’ U+0301
dk(quote) + ‘e’ > ‘e’ U+0301

You can use the index command as you had it for aeiou, if you make the acutevowels string composed characters:
store( plainvowels ) “aeiouAEIOU”
store( acutevowels ) “áéíóúÁÉÍÓÚ”

You can find the composed characters for a-u with acute by searching for “acute” in the character map. I don’t see any combined character for open o and schwa with acute.

1 Like

thanks! I replaced the index command and did it letter by letter; it is working now.

Good work @Steve_White – you can’t see that the vowel strings are in decomposed form just by reading the code! :grin:

I will note one other issue: the ɔ and Ɔ vowels will never match with the diacritic rules, because only one rule from the group will be matched for each keystroke – the rule that matches will be:

+ U+0077 > U+0254

and the rule that includes the deadkey marker won’t match – there is no ɔ key on the base (US) keyboard. Same goes for ə and Ə. To match these, you could move your deadkey processing to be in a secondary group (shortened to only demonstrate with acute, and using any+index to reduce rule count):

group(main) using keys

store(vowelKey) 'aeiouqwAEIOUQW'
store(vowelOut) 'aeiouəɔAEIOUƏƆ'
+ any(vowel) > index(vowel, 1)
+ "'" > dk(quote)     c Quote for acute accent

match > use(deadkeys)

group(deadkeys)

c Note that this is a group without the "using keys" clause

store( plainvowels ) "aeiouAEIOU" 
store( acutevowels ) "áéíóúÁÉÍÓÚ"
store( extendedvowels ) "əɔƏƆ"

c Rules for accented characters
dk(quote) any( plainvowels ) > index( acutevowels, 2 )

c these two vowels do not have a combined acute form
dk(quote) any( extendedvowels ) > context(2) U+0301

c Rules for the accent character itself (type it twice)
dk(quote)  "'" > "'"   c Quote

(You could do this all in one group by matching e.g. dk(quote) + 'q' > U+0259 U+0301, but the secondary group makes it easier to implement more complex processing and reduces repetition)

Guide for groups

1 Like

@Marc’s suggestion is the best approach. A more minimalist change would be to re define your plainvowels store and move single keystroke rules after deadkey rules.

I think part of the confusion is the structure of the rules:

I’d articulate them as:

+ key > output
context + key > output

Where key is what you press on the keyboard, ie you press w to get ɔ. This can be represented as a character or as a virtual key,

context are the characters or state generated by previous keystrokes.

output are the characters generated by the key press.

Your plainvowels is a store of keys, your acutevowels and tildevowels are output, i.e. charcaters produced by the rule.

So plainvowels should have the mnemonic representations of keys, in your case, as indicated by @Marc :

store(vowelKey) 'aeiouqwAEIOUQW'

thanks @Marc ! the keyboard is finally functional; your help is much appreciated :slight_smile:

1 Like