I'm puzzled by the above statements you made regarding the shift keys. I can see in the ASM for in_key_pressed() that SHIFT and SYM are specifically checked for, but I'm not sure why. input_zx.h doesn't list scancodes for upper case characters, so I thought shifted key press detection would require 2 scans, one of the shift key and one for the letter key.
The scan code includes the byte that must be placed on the upper 8 bits of port 0xfe to identify a key row, a bitmask to identify one bit out of the 5 column bits and two bits to indicate whether CAPS and/or SYM should also be pressed.
Besides the compile time constants defined in input_zx.h these scan codes can also be generated at runtime with function in_key_scancode(ascii character). The set of ascii codes that can be identified on the keyboard is in the key_translation_table:
https://github.com/z88dk/z88dk/blob/mas ... _table.asm
So at runtime you could look up the scan code for '$' like this:
dollar_code = in_key_scancode('$');
and it will return a scan code that indicates SYM+4 needs to be pressed.
When you run in_key_pressed, that routine will make sure both sym shift and 4 are simultaneously pressed before returning true.
So the constants defined in input_zx.h are only a subset of the scan codes that are supported and represent what you would want to use in a game, eg, because what you care about are keypresses and not shifted keypresses.
The advantage of using the constants is you save the cost of having the key translation table in memory and the cost of the in_key_scancode() function. The other function that uses the key translation table is in_inkey(). So even though it's legitimate to detect that no keys are pressed with in_inkey()==0, it's cheaper and faster to use in_testkey() to avoid pulling that table into the binary.
What we are talking about is probably 200 bytes here but many games end up looking for extra memory so every byte can count.
The issue I was wondering about is if pressing multiple keys on the spectrum keyboard could generate false positives for caps and sym shift. So, for key 'a' which is lower case, I was wondering if a false CAPS would return false even if 'a' were pressed. But this won't happen because in_key_pressed() does not check if the shifts are not pressed - it only checks, if necessary, if the shifts are pressed. So a check on 'a' won't bother looking at the shift keys and there is no ghosted shift keys problem.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org!
http://sdm.link/slashdot