What follows here comes straight from the Gambas help that pops up when you’re typing code.
But there may be a surprise ...
So I made the following test on an otherwise empty form.
- Put Button1 on a Form
- Added Gambas class file (as copied from Gambas help)
PUBLIC SUB Button1_KeyPress()
IF Key.Alt THEN
Button1.Text = " True " & CString(Time)
ELSE
Button1.Text = " False " & CString(Time)
ENDIF
END
When I run this, it just seems to ignore the IF condition.Whatever key I hit – be it a function key, numeric, abc – it jumps to the 'False' text.
But when I hit the Alt key, it STILL reports false. So it seems it doesn’t recognize the Alt key.
I tried this for other function keys – Enter, F1, Esc, … - with the same result.
Tried it with a ValueBox. Same error.
Surprise ! When I change Key.Alt to Key.AltKey, whatever key I hit on my keyboard suddenly returns TRUE !
The on-screen help gives a warning : “Keys may have functions assigned to them by OS or other programs; you could close/... your program/other programs/system.”
So I made sure no other programmes were running. Even re-booted my computer a couple of times to make sure. Still the same result.
Any ideas? This is essential for my programme to function.