Translate keyboard key to descriptive name

General discussion about anything related to Ultibo.
mark
Posts: 1302
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Translate keyboard key to descriptive name

Postby mark » Fri Dec 14, 2018 2:41 am

Is there a function that will translate a to "a" and page down to "pgdn" or something like that? When a user presses a key that does nothing, I'd like to say "the left arrow key does not do anything."

Regards,
Mark
Ultibo - The Internet of Things that Just Work
User avatar
Ultibo
Site Admin
Posts: 2092
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Translate keyboard key to descriptive name

Postby Ultibo » Fri Dec 14, 2018 6:52 am

mark wrote:Is there a function that will translate a to "a" and page down to "pgdn" or something like that? When a user presses a key that does nothing, I'd like to say "the left arrow key does not do anything."

Not currently but we're open to including such a thing if you'd like to create an array of strings that describe each value, given the smart linking in FPC it would only get included in an application that actually uses them so it wouldn't impact anyone else.

There are two possible cases that might work, the first is to create something based on the ScanCode value returned in the keyboard data which maps to the SCAN_CODE_* values in GlobalConst, there are a maximum of 256 of those. This problem with using those values is they are untranslated so they will not be accurate for international keyboard mappings.

The other option is to base it on the KeyCode value instead which is mapped to the KEY_CODE_* values from GlobalConst and will be correctly translated based on the current keymapping, unfortunately the maximum number of those is 65536 but there are a lot of gaps so it might be easy enough to create a structure that describes the values in a sparse format and allows storing only those values that are relevant.
Ultibo.org | Make something amazing
https://ultibo.org
mark
Posts: 1302
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: Translate keyboard key to descriptive name

Postby mark » Fri Dec 14, 2018 10:32 pm

Ultibo wrote:
mark wrote:Is there a function that will translate a to "a" and page down to "pgdn" or something like that? When a user presses a key that does nothing, I'd like to say "the left arrow key does not do anything."

Not currently but we're open to including such a thing if you'd like to create an array of strings that describe each value, given the smart linking in FPC it would only get included in an application that actually uses them so it wouldn't impact anyone else.

There are two possible cases that might work, the first is to create something based on the ScanCode value returned in the keyboard data which maps to the SCAN_CODE_* values in GlobalConst, there are a maximum of 256 of those. This problem with using those values is they are untranslated so they will not be accurate for international keyboard mappings.

The other option is to base it on the KeyCode value instead which is mapped to the KEY_CODE_* values from GlobalConst and will be correctly translated based on the current keymapping, unfortunately the maximum number of those is 65536 but there are a lot of gaps so it might be easy enough to create a structure that describes the values in a sparse format and allows storing only those values that are relevant.


Thank you. I will have to think about this. For the time being I will say "the last key that you pressed is not programmed to do anything." Mark.
Ultibo - The Internet of Things that Just Work

Return to “Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest