Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3666

The documentation (Trapping the Arrow Keys)

$
0
0

I needed to trap/execute action depending on the pressed Arrow Key in Canvas1.MouseDown.

I wasted my time (without Internet for while) because I had a problem with my code and I was not sure about the arrow values on the keyboard/Canvas.KeyDown(Key).

The used code is:


// Read the image number #…
If key = Chr(28) And Img_Nbr > 1 Then // Left Arrow
  Img_Nbr = Img_Nbr - 1
ElseIf key = Chr(29) And Img_Nbr < Img_Cnt Then // Right Arrow
  Img_Nbr = Img_Nbr + 1
ElseIf key = Chr(30) Then // Up Arrow
  Img_Nbr = 1
ElseIf key = Chr(31) Then // Down Arrow
  Img_Nbr = Img_Cnt
Else
  System.DebugLog "Unknow Key"  // *
End If

I rarely get the Left Arrow fired, but the key works fine elsewhere.

Is there’s something wrong ?

  • I was not able to transform Key to a decimal value… tired !

Do you think the above code (if correct) must be set back in the documentation (instead of nth times the same other code) ?
Other code to deal with the Arrow Keys (Keyboard.AsyncKeyDown(123) to &26)

17 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 3666

Trending Articles