usually, you will get the scancode right from the keyboard port (0x60) at keyboard interrupt (IRQ1). Each key on your keyboard has its own number (the scancode) which you have to interprete with your own mapping table:
E.g. here, my key #16 is 'A' character. Let's say for the purpose of the example there is an arabic symbol '?' on it that you want displayed if "arabic mode is turned on" ...
note: i guess ? is _not_ arabic char, but i can't compose arabic chars with this keyboard and the board doesn't support them anyway, so let's just pretend it is.When hitting the key, the IRQ1 is fired and reading the kb port gives "16". Your IRQ handler will then look some of its internal variables (like SHIFT&ALT status) to know how it should decode that.
Code:
/*** pseudocode for multilinguist keyboard input
* assuming there's no 'uppercase' in arabic and that
* shift lock can be used to toggle mode.
*/
interrupt keyboard() {
static boolean arabic=false;
static boolean shifted=false;
byte scancode=Keyboard.getByte();
switch(scancode) {
case SHIFT_PRESSED:
shifted=true;
arabic=false;
break;
case SHIFT_RELEASED:
shifted=false;
break;
case SHIFTLOCK_PRESSED:
arabic^=arabic;
Keyboard.UpdateLeds(arabic);
break;
default:
if (arabic) PushCharacter(arabic_map[scancode]);
else if(shifted) PushCharacter(shifted_map[scancode]);
else PushCharacter(latin_map[scancode]);
break;
}
}
shifted_map[16] would for instance hold ascii char #64 ('A'),
regular_map[16] would hold ascii char #96 ('a')
and arabic_map[16] would hold ascii char #134 which would be the code for your arabic character '?'