Recent

Author Topic: Crt.KeyPressed() on Linux: getting scancodes  (Read 1806 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 6692
Crt.KeyPressed() on Linux: getting scancodes
« on: January 02, 2023, 09:34:09 pm »
If a console (non-GUI) program is running in a shell window on e.g. KDE on Linux (e.g. Debian 12), does it have any chance of recovering the scancode when e.g. the <F1> key is pressed?

The documentation for ReadKey() says that

Quote
If an extended or function key has been pressed, then the zero ASCII code is returned. You can then read the scan code of the key with a second ReadKey call.

but I suspect that this might only apply to the system console, or that it requires the keyboard to be set to raw mode which the Crt overview explicitly says is a problem.

Application is a Telnet client with comprehensive hooks for Telnet options and NVT controls. However I'd emphasise that this is test code and not at all important: I'm asking more for curiosity than anything else.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

MarkMLl

  • Hero Member
  • *****
  • Posts: 6692
Re: Crt.KeyPressed() on Linux: getting scancodes
« Reply #1 on: January 03, 2023, 08:42:26 pm »
Please ignore this. I was, without thinking things through, expecting function keys etc. to work while debugging using the IDE: and that's quite simply a non-starter due to the limitations of input in the console window.

It is possible to set breakpoints to intercept extended codes (i.e. 0x00 followed by a scancode) if a program is started from a shell and the IDE/debugger is then attached to it using the Run -> Attach to program... facility. There might however still be certain keys that appear dead, which is almost certainly down to the configuration of the desktop environment; also some non-ANSI keys might have a prefix depending on the codepage and widget set.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018