Function Keys

Hi,

I am having a problem and I don’t find a solution.
Could you help me, please?

I need to check function keys pressed by user, like F1 to F12. But KeyDown event receive only a string and I can’t know if it is the required function key or another character. For example: F2 has the same value of “”. At WebControl this event receive a RealBasic.KeyEvent and it could work but this is a desktop application.

Then I would like to know if you have any suggestion to solve my problem.

I think that on previous versions of RealBasic, even on desktop, this event received a KeyEvent instead os a string. Am I right?

Thanks.

No
Its always gotten a string

You can test for the function keys with

select case Key
case chr(200)
   // F1
case chr(201)
   // F2
case chr(202)
   // F3
etc

Desktop control and windows supply the key as a String.

Web controls and pages supply the key as a KeyEvent.

Just a note…

is the same as … case “É” …

This ( 201 ) is the code for that accented E character, so no obvious (to me) way to tell F2 from the É character on a keyboard with that key.

[quote=64656:@Chris Carter]Just a note…
is the same as … case “É” …
This ( 201 ) is the code for that accented E character, so no obvious (to me) way to tell F2 from the É character on a keyboard with that key.[/quote]

And “É” is directly accessible and frequently used on a French Canadian keyboard :frowning:

In VB, function keys generate a specific character chain starting with chr(0). Its much more sensible. Without breaking existing Xojo code, it would be nice for instance to be able to use a keyboard.something for modifier keys when a function key is pressed instead of the regular alphanumeric key.

Perhaps checking Keyboard.AsyncKeyDown in the KeyDown event handler would work better:

If Keyboard.AsyncKeyDown(&h78) Then Msgbox("F2") Return True End If