[Gambas-user] Keys

Benoit Minisini gambas at ...1...
Fri Jun 4 19:38:27 CEST 2004


On Friday 04 June 2004 09:57, Eilert wrote:
> Hi,
>
> Devilyn schrieb:
> >  How or What command do you use to know when a key is
> > pressed.. or how can I identify if some one presses
> > keys A to Z..
>
> For TextArea1 it is TextArea1_KeyPress().
>
> Within the event function, there is key.Code you can ask for the ASCII
> value of the key e. g. by using a select case thing. Then you have some
> key.XXX functions that return values for special keys (Backspace, Return
> etc.).
>
> > Oh no I do not need to know how to use F1 - F12.. Just
> > the keys A through Z if possible.
>
> Well, uppercase A is 65, Z is 90, lowercase a is 97 and z is 122.
>
> Try it out - does it help?
>
> Rolf
>

Be careful! Key.Code returns the code of the key. Use Key.Text if you want the 
text typed by the user. To test a specific key, for example 'A', use Key.Code 
= Key["A"]. To test 'F12', use Key.Code = Key["F12"], and so on. Never use 
hard coded values directly, this is a very bad programming pratice!

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list