Asc(key) ---> difference between windows and linux

Hi everyone, I’m having a problem with the asc (key) function, used inside a KeyDown method.

In practice, under windows, pressing the F8 key corresponds to an ASC 207, while, under linux (ubuntu), it returns 197.

Taking into account that I started working with linux less than 10 days ago, does anyone have any indication to give me?

And under JS… :open_mouth:

Just map them. Those keys don’t have the same ascii value in Mac, Linux and Windows. I don’t think their “ascii value” are even defined universally (and don’t let me get started to a discussion between ascii values and physical keys values).
But you can normally assume a code you get on an OS will be the same for the other installations of that OS. Just map/convert them to a table you define (e.g. the codes for one given OS).

1 Like

I do avoid using function keys for my users. If possible, translate the needs to menu items and set a speed access control-letter, alt-letter, to them. This way you avoid weird mapped Fn-keys and codes, and make those functionalities more easily findable without needing to memorize.

maybe you can use keycode system? but i don’t know if it behave same in windows and linux world

If Keyboard.AsyncKeyDown(&H64) Then
  MessageBox "Yeah F8"
End If

Yes, it’s the same solution I have realized. Thanks :wink:

No, that’s even worse, because it depends on your keyboard settings.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.