Keyboard: Differ between LEFT and RIGHT key

  1. 6 weeks ago

    Hello
    I'm pretty new to Xojo and I try to create a keymap App (Desktop, macOS). I'm using the Keyboard module which works fine to catch the pressed key: http://docs.xojo.com/Keyboard
    There is only one problem: How can I differ between LEFT SHIFT and RIGHT SHIFT? Similar problem for any key that exists twice on the keyboard (CMD, ALT).

  2. Norman P

    Feb 21 Pre-Release Testers, Xojo Pro outside enjoying the fresh air

    you probably need to test using he raw keycodes for that (see http://docs.xojo.com/Keyboard.AsyncKeyDown )
    beware this has a different set of issues like keycode NOT being common across various keyboard layouts

  3. Edited 6 weeks ago

    Tnx, I'm doing it that way, just with decimal values.
    But where's the difference in checking between in Hex or in Dec? In Hex "a" is 0, similar to Dec. So the Hex value list doesn't offer me more values to check. The special keys can be checked as well as mentioned at top of http://docs.xojo.com/Keyboard but there's no check difference on f.e. the left and right SHIFT key.
    I assume/fear Xojo does just not support that.

  4. Norman P

    Feb 21 Pre-Release Testers, Xojo Pro outside enjoying the fresh air
    Edited 6 weeks ago

    no different if you use hex or decimal
    just that you end up needing to use the raw scancodes
    and scancodes are NOT portable across keyboard layouts etc
    this page gives an ok description of what you need along with a LOT of the scan codes for a US keyboard
    https://handmade.network/wiki/2823-keyboard_inputs_-_scancodes,_raw_input,_text_input,_key_names

  5. I see, this turns into rocket science...
    If I read that right, I can check by scancodes only in Windows (not Mac or Linux). Furthermore I don't find any function returning a scancode or keyvalue in Xojo. You only can check for a key pressed value.

    http://docs.xojo.com/Keyboard :

    ...
    Windows
    You can pass raw Win32 key codes to AsyncKeyDown.
    ...

  6. Norman P

    Feb 21 Pre-Release Testers, Xojo Pro outside enjoying the fresh air

    @FaraiAschwanden I see, this turns into rocket science...

    It can VERY quickly

    AsyncKeyDown may be the thing you need just that you would have to check EVERY key
    http://docs.xojo.com/Keyboard.AsyncKeyDown

    doing this in a short period timer might work well enough

    the other thing is you do NOT get keydown events for ANY of the modifier keys (ALT, SHIFT, CMD) etc but asynckeydown could be used to test them

    I do not know if the MBS plugins gives you a way to access the lower level APIS that access the keyboard but if they do that might be an option

  7. I'm already using AsyncKeyDown inside a Timer and it works well. The special keys can be checked as well (see Properties on your provided link), just does not differ between the LEFT and RIGHT of a specific special key, like http://docs.xojo.com/Keyboard.ShiftKey

    I tried the RawCodes but that doesn't seem to work (on Apple).

    Tnx anyway for you appreciated help.

or Sign Up to reply!