The above code is similar to the following (http://www.freepascal.org/docs-html/rtl/keyboard/getkeyevent.html). The returned string from KeyEventToString(K) works for many keys. For example, pressing the F10 key returns 'F10', Ctrl+F10 returns 'CTRL F10', Alt+F10 returns 'ALT F10'. However, pressing Alt+H returns 'ALT Key with scancode 8960' which isn't particularly usable.

Perhaps using KeyEventToString(K) is not the best solution. Other suggestions?

These codes might be useful. However, what accompanying Pascal code do I need to translate a physical keypress into one of these codes (e.g., press the Esc key to return $011B). Also, I would need F11 and F12 together with associated Shift, Ctrl, & Alt.

I have been using something like the following but the return Keycode for special keys is nonstandard. (Note the required Offset. If Offset = 0 (ignored) then some Keycode overlap -- for instance, the Keycode for "0" is 48 and the Keycode for Alt+B would also be 48.) I think there should be a generic way to do this in console mode so that some kind of standard codes would be returned which could then be queried with a case statement.

Perhaps using KeyEventToString(K) is not the best solution. Other suggestions?

Indeed, because not every key combination that is pressed is actually 'translated'.

Quote

These codes might be useful. However, what accompanying Pascal code do I need to translate a physical keypress into one of these codes (e.g., press the Esc key to return $011B). Also, I would need F11 and F12 together with associated Shift, Ctrl, & Alt.

I can't get your code to respond to Ctrl+S (I would need this for file-save). I put in the following debug writelns but no output at all for Ctrl+S. All of the other Ctrl+charkeys respond as expected. I tried this on two computers with the same keyboard and on one of these computers with two different keyboards. Also, your short version of April 21 gives the same result.

Perhaps using KeyEventToString(K) is not the best solution. Other suggestions?

Indeed, because not every key combination that is pressed is actually 'translated'.

Quote

These codes might be useful. However, what accompanying Pascal code do I need to translate a physical keypress into one of these codes (e.g., press the Esc key to return $011B). Also, I would need F11 and F12 together with associated Shift, Ctrl, & Alt.

I can't get your code to respond to Ctrl+S (I would need this for file-save). I put in the following debug writelns but no output at all for Ctrl+S. All of the other Ctrl+charkeys respond as expected. I tried this on two computers with the same keyboard and on one of these computers with two different keyboards. Also, your short version of April 21 gives the same result.