Ciao oli and welcome to thinBasic community.
Console_Inkey, in case of extended keyboard pressing, returns a 2 bytes string where first byte is null while second byte is the virtual-key code.
You can get values of virtual-key codes from http://msdn.microsoft.com/en-us/library/ms645540(VS.85).aspx
Unfortunately I've setup virtual-key codes in UI module and not in Console module. And also I've forgot to add OEM virtual-key codes (I will add in next update).
I will consider to move those virtual-key codes in thinBasic Core engine so they will be available to all modules.
Anyway, "." and "+" and other codes are :
[code=thinbasic]%VK_OEM_PLUS = &HBB ' "+" any country
%VK_OEM_COMMA = &HBC ' "," any country
%VK_OEM_MINUS = &HBD ' "-" any country
%VK_OEM_PERIOD = &HBE ' "." any country[/code]
So your code can be something like:
[code=thinbasic]
Uses "Console"
dim s as string
dim i as long
%VK_OEM_1 = &HBA ' ";:" for US
%VK_OEM_PLUS = &HBB ' "+" any country
%VK_OEM_COMMA = &HBC ' "," any country
%VK_OEM_MINUS = &HBD ' "-" any country
%VK_OEM_PERIOD = &HBE ' "." any country
PrintL "Please press 'q' to exit."
DO
s = Console_InKey()
sleep(0)
i = len(s)
select case i
case 1
PrintL "You pressed the " + s + " key."
case 2
Print "You pressed an extended key: " + Hex$(Asc(s, 2))
'--Check second char of returned string
Select Case Asc(s, 2)
Case %VK_OEM_PLUS
PrintL " + (plus)"
Case %VK_OEM_COMMA
PrintL " , (comma)"
Case %VK_OEM_MINUS
PrintL " - (minus)"
Case %VK_OEM_PERIOD
PrintL " . (period)"
Case Else
PrintL " ... something else"
End Select
case 3
select case asc(right$(s, 1))
case %CONSOLE_MOUSE_MOVED
PrintL "You moved the mouse to" + Str$(Asc(LEFT$(s,1))) + "," + LTrim$(Str$(Asc(Mid$(s, 2,1))))
case %CONSOLE_DOUBLE_CLICK
PrintL "You double clicked to" + Str$(Asc(LEFT$(s,1))) + "," + LTrim$(Str$(Asc(Mid$(s, 2,1))))
case %CONSOLE_LBUTTON
PrintL "You pressed the left button"
case %CONSOLE_RBUTTON
PrintL "You pressed the right button"
case %CONSOLE_MBUTTON
PrintL "You pressed the middle button"
case %CONSOLE_MOUSE_WHEELED
PrintL "Mouse wheeled"
end select
end select
LOOP UNTIL (i OR s = "q")
[/code]
Ciao
Eros
Bookmarks