Topic 'a' or ['A']

We have two new locations for Keyman technical support:

The Tavultesoft Forums are now read only.


# 'a' or ['A']   2016-03-25 05:36:28.623
br Julian Griffin OSL
In a Mnemonic Layout keyboards design, the following code seems to be interchangeable:
:
'a' ≡ ['A']
'A' ≡ [SHIFT 'A']

   Which is the preferred method:
:
   ['A'] & [SHIFT 'A']
or
   'a' & 'A'

   For Ctrl & Alt the [ ] are needed so it would seem the [ ] would be consistent. But for keys that do not have a lowercase and uppercase eg !, ", £, $, %, ^ the [ ] do not seem to function, so these need to be just ' '.

   Please advice as to the best coding practice.

Thank you.
Julian
# RE: 'a' or ['A']   2016-03-27 08:24:57.670
Marc Durdin
Tavultesoft Staff
There's a subtle difference between 'a' (character code) and ['a'] (virtual character key) and 'A' and [SHIFT 'A'], which won't really be visible in the letter keys but is relevant for punctuation and numeric keys:

+ 'A' means the key and modifier which generates the capital A on the base layout.

+ [SHIFT 'A'] code means Shift+the key which generates the capital A character on the base layout.

This is clearer when looking for instance at '2' key.

+ '@' means the key and modifier which generates '@'.

+ [CTRL '@'] means Ctrl+the key which generates '@'. On a US keyboard, this would be the Ctrl+2 key, but on a UK keyboard, this would be Ctrl+'.

+ ['@'] means the key which generates '@', without modifiers... a little tricky! It means the K_2 key on a US keyboard, and the K_QUOTE key on a UK keyboard.

Does that make sense? In terms of coding practice, using character codes rather than virtual character keys where possible is my recommendation. Virtual character keys should be reserved for those specific situations where you can't accomplish what you need with character codes.