Keyboard commands

  1. 4 months ago

    Hello everyone,

    I am trying to alter the value of a specific slider when a directional button is pressed. For example, if the down arrow is pressed, the slider value will decrease by a value of 100. However, the timer is throwing an error: "Timer has no member named AsyncKeyDown"

    I'm probably misreading / misunderstanding the example code from the documentation. Could someone provide some insight?


  2. Emile S

    Jun 13 Europe (France, Strasbourg)
    Edited 4 months ago

    Do that in the Window’s KeyDown Event (you will add first), not in the Timer.

  3. Kem T

    Jun 13 Pre-Release Testers, Xojo Pro, XDC Speakers New York

    I think you want Keyboard.AsyncKeyDown.

  4. @Emile S & @Kem T Thank you both! I've added Keyboard.AsyncKeyDown as an event handler, and it works. However, now I need to find a way to disable any other sliders from being affected by the use of arrow keys.

  5. Emile S

    Jun 13 Europe (France, Strasbourg)

    Return True i the Event…

  6. Thanks @Emile S. That did the trick. I really need to do some serious reading. I'd prefer to understand what I'm doing and why :P

  7. Michel B

    Jun 13 Pre-Release Testers

    @Chad Y I've added Keyboard.AsyncKeyDown as an event handler, and it works.

    Uh ? AsyncKeyDown is not an event, it is a property.

  8. @Michel B

    * I have added Keyboard.AsyncKeyDown to the KeyDown Event

  9. Tim H

    Jun 13 Pre-Release Testers Portland, OR USA

    You don't need to (nor should you) use the Async variant in a KeyDown event. You are passed the Key that was pressed as an argument. Use that. For reference

    if Key = chr(28) then
        // Left Arrow
    ElseIf Key = chr(29) then
       // Right Arrow
    Elseif Key = chr(30) then
       // Up Arrow
    ElseIf Key = chr(31) then
       // Down Arrow
  10. Thanks @Tim Hare. I'll give this a shot! I won't be able to test this until tomorrow though.

  11. Dave S

    Jun 13 San Diego, California USA

    I'd use "SELECT CASE" instead of IF/ELSEIF .... would get cumbersome if you added a few more key conditions.

or Sign Up to reply!