Maybe a short explanation concerning the "natural keyboard" in MAME could be useful.
The natural keyboard shall offer an easier way to type characters into the emulation. When you press a key, that key should also appear in the emulation. This may look obvious at first, but it has some challenges. For example, typing a double quote means that you use the shift key with the key left from the return key - but only on English keyboards. On a German keyboard, the double quote is Shift-2. If we limited the mapping to English keyboards, the "natural" keyboard would make no sense for other locales.
For that reason, not the "scan code" but the "character code" must be used. That is, we have to rely on the output of the PC keyboard driver which applies the locale setting.
This is one of the problems. The next problem is that keys have to be mapped to multi-key presses in the emulation. When I press the number key (#), it is a single keystroke on my German keyboard (without shift), but in the TI emulation, the 9901 lines of the Shift key and of the 3 key must be activated.
Here is the input pin definition from the ti99_4x.cpp file:
PORT_START("COL2") // col 2
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3 # ERASE") PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') PORT_CHAR(UCHAR_MAMEKEY(F3))
This line means that bit 4 (from the right) will be reset (active low) on the COL2 line of the 9901 when the keyboard driver delivers a "3" character. When it delivers "#", this will additionally assert the SHIFT line (first modifier). When it delivers F3, it will assert the second modifier, which is FCTN. This will, however, be delayed until COL0 is processed, which contains the SHIFT and FCTN keys.
The PORT_CODE attribute is used for the "emulated keyboard". When the key with the scan code of KEYCODE_3 is pressed, this line is asserted. However, no modifiers are used here. So in order to get the "#" character, the shift key on the TI keyboard must also be pressed. However, this means that I have to press shift+3, which is "§" on my keyboard, hence there is no correspondence between the keys on the PC keyboard and the emulated keys.
The next and worst problem of the natural keyboard (which may become a true showstopper) is that it can only translate characters that are delivered by the keyboard driver. For CTRL combinations, this is not always possible. The CTRL-C key combination is often associated to a break signal; other CTRL keys do not deliver any character. If we want to get a CTRL-1 in the TI emulation, we would have to identify a character that is produced by the keyboard driver for this keystroke. Because of this issue with the CTRL key, it is not a valid modifier in the MAME natural keyboard mapping, so there is no way to define those key combinations.
You can try it this way:
10 CALL KEY(0,K,S)
20 PRINT K
30 NEXT K
Press Ctrl-1 in emulated mode and then in natural mode.
Apart from this issue, the natural keyboard is very slow. You notice it when you type characters rapidly.
For all of these reasons, I actually never use the natural keyboard mode, and I highly recommend to use the emulated keyboard even if it means that you have to learn to type without seeing the proper character on your key.