No key codes for special keys?

Howdy Doody,

I have my code below, which displays the key code of a depressed key.
However, when I press the Ctrl key, the Alt key, the Cmd key, or the Shift key, nothing displays - is this expected behaviour?

// DISPLAY THE ASCII KEY CODE IN THE FIRST TEXT FIELD Dim ConvertedToASCIIEncoding as String = DefineEncoding(inStringToConvert,Encodings.ASCII) Dim ConvertedASCII_Code as Integer = Asc(ConvertedToASCIIEncoding) AsciiField.AppendText Str(ConvertedASCII_Code)

I can press Alt -2 for example and all is ok, but Alt alone displays nothing?

How are you acquiring the key? What event? Pressing the Alt key doesn’t trigger a KeyDown event, for example. It is only a modifier. It’s only when you also press the modified key (“2” in your example) that you get a KeyDown.

Tim,
My code is in the keydown event.

So is it worthwhile, or even possible, to get the key code for such keys?

[quote=106333:@Richard Summers]Tim,
My code is in the keydown event.

So is it worthwhile, or even possible, to get the key code for such keys?[/quote]

Richard, check out http://documentation.xojo.com/index.php/Keyboard

For instance :

If keyboard.AltKey then MsgBox "Option/Alt key" end if

Thanks Michel.