What's the best way to know the ASC value of CNTL+keyboard-letter?

As an example, CNTL-D yields an ASCII value of 04. But how do I know that without experimenting to see what I find via a program? Are these key combinations documented anywhere so I can know how to test for certain key combinations - rather than having to experiment to learn the values for every combination I want to capture?

Sure. just bring up your browser and search for “ASCII Table”. You’ll find dozens of them.

There is a mapping based on the English alphabet. CNTL-A = 01, CNTL-Z = 26. D being the fourth letter returns 4.

I am familiar with these tables, but they don’t describe key combinations (i.e. CNTL+Letter).

Thanks, that sounds like a good answer, wonder if that is actually documented anywhere.

Its documented just about everywhere that hosts a standard ASCII table… remember Google is your friend
Also remember that there are in some cases multiple keys that emit the same character.

  • Ctrl-M and [RETURN] are both 13 or 0x0D
  • Ctrl-C and [Enter] are both 3 or 0x03
  • Ctrl-H and [BackSpace] are both 8 or 0x08
  • Ctrl-I and [Tab] are both 9 or 0x09

A very simple way to proceed is to use System.debuglog str(ASC(Key)) in the Keydown event.

I am just trying to learn here…
Here is a link to a table (randomly selected out of many): https://commons.wikimedia.org/wiki/File:ASCII-Table.svg
I do not see the CNTL-Letter references here (perhaps I am being very dense). Am I missing something?

You won’t see anything when pressing Ctrl-A etc.

as some keys are intercepted and processed by the operating system prior to the app getting them.
the specific keys this applies to may be different between OSX and Windows

and here is one also chosen at random… :slight_smile:

http://www.robelle.com/smugbook/ascii.html

And it’s all quite mathematical. There are 4 “pages” of 32 characters. That takes 5 bits. The Control and Shift keys add 1 bit each (think actual wires in the keyboard, each character is 7 bits/wires). The lowercase characters are in the “page” from 96-127 (“a” is 97). Bits 6 and 7 are “on” or “1” by default. The Control key clears the 6th and 7th bits (hex 60, decimal 96), so you subtract 96 to get and ASC value of 1 for Control-A. In the same way, the Shift key clears the 6th bit, so you subtract 32 - uppercase A is 97-32 = 65.

Uppercase = subtract 32
Control = subtract 96