Language independend Keyboard Input
Posted: Fri Apr 04, 2003 12:11 pm
Code updated For 5.20+
Restored from previous forum. Originally posted by freak.
PureBasic's Keyboard Functions use the US Scancodes as Constants.
However, in other countries, the leyout of the keyboard is different.
In Germany, for example Z and Y are switched, and i hear in France,
there are also some differences.
So here is a procedure to always get the right Key for the User's keaboard out of the PB Constant.
Especially people who write programs for users from different countries, should use this.
Use it like this:
Note: This should not be used for special Keys, like the Arrows, the NUMPAD or CONTRIL/ALT Keys. Use the usual PB Constant directly here. These Codes are the same on each Keyboard anyway.
So here is the Procedure:
Hope it is usefull..
Timo
Restored from previous forum. Originally posted by freak.
PureBasic's Keyboard Functions use the US Scancodes as Constants.
However, in other countries, the leyout of the keyboard is different.
In Germany, for example Z and Y are switched, and i hear in France,
there are also some differences.
So here is a procedure to always get the right Key for the User's keaboard out of the PB Constant.
Especially people who write programs for users from different countries, should use this.
Use it like this:
Code: Select all
; at start:
KeyZ.l = GetRealKey( #PB_Key_Z ) ; get the real Scancode
; later in the program:
If KeyboardPushed(KeyZ) ; test if Z was pushed
Debug "Z was pushed"
EndIf
Note: This should not be used for special Keys, like the Arrows, the NUMPAD or CONTRIL/ALT Keys. Use the usual PB Constant directly here. These Codes are the same on each Keyboard anyway.
So here is the Procedure:
Code: Select all
Procedure.l GetRealKey(PB_KEY.l)
Protected VirtualKey.l
VirtualKey = MapVirtualKeyEx_(PB_KEY, 1, $0409)
ProcedureReturn MapVirtualKeyEx_(VirtualKey, 0, GetKeyboardLayout_(0))
EndProcedure
Timo