KeyDown and Cursor Keys

is that the correct way to handle cursor up and down keys?
what about mac os? have xojo key constants?

[code]Function KeyDown(Key As String) Handles KeyDown as Boolean

Var DeltaY As Integer = 3.0
Select Case Key
Case Encodings.ASCII.Chr(30)
ScrollOffsetY = -DeltaY * 10.0
Case Encodings.ASCII.Chr(31)
ScrollOffsetY = DeltaY * 10.0
End Select

End Function
[/code]

If you mean the “up and down arrow keys”, see: http://documentation.xojo.com/api/hardware/keyboard.html
and the last example:

If Keyboard.AsyncKeyDown(125) Then // do something with the down arrow key... End If If Keyboard.AsyncKeyDown(126) Then // do something with the Up arrow key... End If

or you can pass keys in hex: If Keyboard.AsyncKeyDown(&h7D) Then ’ down arrow

I believe this will work for Windows and MacOs.

I believe that only a few keys have been defined in XOJO (eg: alt, ctrl, shift, option) as a readonly property of the keyboard object. see: http://documentation.xojo.com/api/hardware/keyboard.html

Yes, that is the correct way to handle them.

@Craig Hyde Don’t use Keyboard.Asynckeydown in the KeyDown event. Always use the Key parameter passed to you. The example code in the docs would be appropriate to use in a Timer.

ahh in the debugger the “Key” String from KeyDown is shown as US-ASCII

the KeyCodes from docu seems only for AsyncKeyDown.
this information about AsyncKeyDown was also interesting for me.

thank you all