0

I am creating a database of keyboards using MySQL and PHP.

Is there a standard way to number the individual keys on a keyboard based on their physical position?

I want to use these numbers in the index column of my database. I have been looking at this, but it is missing some of the newer keys:

https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/com.ibm.aix.keyboardtechref/doc/kybdtech/Key.htm#dbffbe3450dagi

Using scancodes might be an alternative, but converting back and forth between decimal and hexadecimal would be an annoyance. Also, some keys sometimes have two sets of scancodes, which would be problematic for my database. Thanks.

posfan12
  • 2,541
  • 8
  • 35
  • 57

1 Answers1

1

Short answer: No.

Long answer: There are more keyboards out there than you could catalog in a lifetime. Every major vendor has produced localized keyboards for hundreds of countries in dozens of versions and iterations over the last thirty-plus years. Some countries have more than one keyboard layout, like Canada, which has both US English and Canadian French.

Even focusing on a single vendor with a relatively standardized layout, like Apple, would require hundreds of hours of work to identify, precisely, the nature of each key and its physical location and shape on the keyboard.

The scancodes are fairly consistent, but I'm not sure that's much help when the key itself may be remapped in software to do different things, or may have different meanings in different languages.

You're going to need to experiment, explore, and probably buy an embarrassing number of keyboards on eBay if you want to create a comprehensive database.

tadman
  • 208,517
  • 23
  • 234
  • 262
  • I am not trying to model every single keybaord out there. I am mainly trying to stick with the ANSI and ISO standards, as well as several Macintosh keyboards. I am considering switching to USB scancodes, since they seem to be similar on PC and Mac. I'm a bit hazy on how ISO keyboards vary from country to country, though, and am not sure yet how to use hexadecimal values as an index column in MySQL. – posfan12 Mar 19 '19 at 11:29
  • "Hexadecimal" values are just numbers. Numbers are just `INT` in MySQL parlance. – tadman Mar 19 '19 at 18:04
  • How do I type hexadecimal values in the Workshop? – posfan12 Mar 19 '19 at 23:25
  • 1
    If you mean "hexadecimal" as in "hexadecimal numbers" then you convert them with `CONV('20', 16, 10)`. If you mean "hexadecimal" as in hex encoded binary data, then you [can do that this way](https://stackoverflow.com/questions/3126210/insert-hex-values-into-mysql). – tadman Mar 20 '19 at 15:35
  • Which method would allow me to type the hex values using the keyboard into the "Result Grid" in Workshop without constructing a complete SQL query? – posfan12 Mar 23 '19 at 00:20
  • "Hex value" is too ambiguous a term to be meaningful. Do you mean "base-16 numbers' or do you mean "hex-encoded binary data"? – tadman Mar 23 '19 at 18:56
  • I don't really care which as long as I can 1) use them as an index column and 2) type the values into MySQL Workbench result grid. – posfan12 Mar 25 '19 at 23:24
  • That's not what I'm asking. I'm asking *what data you're trying to encode*. – tadman Mar 26 '19 at 00:24