|
-
Dec 29th, 2018, 09:13 PM
#1
Thread Starter
Member
Mapping a Unknown keyboard layout to functions with in a application
Hi Everyone
I need some advice. I have written a very powerful Point of sale software but I am a little stuck. I have some terminal that are great (2ghz with 2gb ram) and a touch screen plus keyboard my problem is I can not configure the Keyboard to use a settings I know. e.g. press the first key and it would produce a A second key B etc etc.
MY problem is this
Same keyboard on both machines (Toshiba LKBST-65) but first key would product a "Z" on one machine and on the other machine would product a "F1" key
How can I "map" the given keys to my Keyboard functions (in my case I would press the A key and this would display the sign on screen)
Any advice or example code would be most welcomed as this is starting to drive me nuts
-
Dec 29th, 2018, 09:42 PM
#2
Re: Mapping a Unknown keyboard layout to functions with in a application
This sounds like an OS issue rather than an application issue. The keyboard layout must be set differently is each OS so that's what you should be changing.
-
Dec 30th, 2018, 01:13 PM
#3
Thread Starter
Member
Re: Mapping a Unknown keyboard layout to functions with in a application
The keyboard is programmable Point of Sale keyboards and the machines use to run different Point of sale applications on them (hence why the keyboard layout is different between machines)
I have tried to contact Toshiba a few times but they no longer support this keyboard so thier programming software for it is not available.
What I would ideally like is a small app i can run and press each key in turn and have it record the scan code or something that makes the key unique and then load that into my PoS application at start up
-
Dec 30th, 2018, 03:56 PM
#4
Re: Mapping a Unknown keyboard layout to functions with in a application
Assuming you have the ability to read the unique value for each key (and you know what physical keys there are, or at least which ones you care about), that is a reasonably easy thing to do.
You can use the same kind of system that many games use, which is basically a series of "press the key you want to use for X". For a game, X would be left/right/fire/etc.
Simply loop that for each key that you care about, and store the unique value from the key pressed to an array. When all are done store the array to a file, and load it in your main app when it starts (you probably want to have default values stored within your main app, in case the file doesn't exist).
In your main app, when a key is pressed you can loop thru the array to find what the unique value refers to (which will be indicated by the position you found it in the array), then have a Select Case to act on the keypress appropriately.
To avoid having to deal with "magic numbers" in your code, I recommend creating an enum based on the names of the keys (perhaps keyboardKey1, etc) with the value referring to the related array position.
-
Dec 30th, 2018, 04:21 PM
#5
Thread Starter
Member
Re: Mapping a Unknown keyboard layout to functions with in a application
@si_the_geek
Thanks for the post and yes that is just what i want to do but I have never really managed to get scan codes or anything like that to work before. (i can not even get F10 to work in a VB app) do you know of any example that would help with what i am trying to do?
-
Dec 30th, 2018, 04:44 PM
#6
Re: Mapping a Unknown keyboard layout to functions with in a application
Set the KeyPreview property of a form to True, and put this code in the KeyUp event:
Code:
'Detect the key pressed
Dim KeyPressed As Keys = e.KeyCode
'Do something
MessageBox.Show (KeyPressed.ToString, "KeyUp")
-
Dec 30th, 2018, 04:59 PM
#7
Thread Starter
Member
Re: Mapping a Unknown keyboard layout to functions with in a application
And does that work fine with the Function keys as well as Shift plus key (ie shift & F1) etc
-
Dec 30th, 2018, 05:16 PM
#8
Re: Mapping a Unknown keyboard layout to functions with in a application
Try it and see.
If it doesn't provide all the functionality you want, check out what other properties the e parameter has (and if appropriate, read the help for them to see examples etc).
-
Dec 30th, 2018, 08:27 PM
#9
Thread Starter
Member
Re: Mapping a Unknown keyboard layout to functions with in a application
@si_the_geek
Thank-you I shall create a small app and try it on the terminal in the next few days and report back
From the test I have done it only detect shift on its own and not shift and another Key
-
Dec 31st, 2018, 04:36 AM
#10
Re: Mapping a Unknown keyboard layout to functions with in a application
My example was simple, so doesn't make use of all functionality that is available... my previous post explains how to find out the rest (and in this case it should be fairly easy).
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|