That's not the same. X events, shown by xev, are not scan codes. There is a Linux utility called showkey that is supposed to show the scan codes seen by the kernel. I've never used it. Instead I've used, actually written an MS-DOS app, that read the keystrokes directly from the keyboard controller. Otherwise the BIOS would read the keystrokes for you, giving you the ASCII instead.
Well, then OP might elaborate about what he wants to achieve?That's not the same.
[…]
I'm trying to find out what control character is generated by, for example the BACKSPACE key, in FreeBSD.Well, then OP might elaborate about what he wants to achieve?
I'm not using X.
$ echo -n ^M | hexdump
0000000 000d
0000001
initscr();
noecho();
cbreak();
timeout(10);
int ch;
while(1) {
ch = getch();
if(ch != ERR) {
printf("Key : "%s\n", keyname(ch));
refresh();
}
}
A way to get the scancodes on FreeBSD would be nice, booting MS-DOS or FreeDOS for such a task feels ... wrong ... somehow.
Emacs is the problem! M-x describe-key shows 'C-h-' when Backspace is pressed.Emacs' own `M-x describe-key` is usually enough to solve emacs problems.
No context neededEmacs is the problem!
I used the term 'scan code' because that is what I was used to saying many years ago with my original PS/2 keyboard. I was simply trying to find out why FreeBSD knew what to do when I pressed Backspace and Emacs didn't. I guess the answer is far more complicated than I want to know.No context needed
But seriously, please read about the XY-problem. It's much more efficient to directly describe the actual problem, which in this case had nothing to do with scan codes. In the original meaning, a scan code is a way to encode a (physical) position in the keyboard matrix, it's derived from "scanning the matrix" by pulling a specific matrix row to low and then checking which column goes low, allowing to deduce which key is pressed in this row (or, of course the other way around with rows/columns exchanged). In today's keyboards, a keyboard processor built into the keyboard is doing that. In a broader sense, although not entirely correct, the term "scan code" is also used for codes sent "over the wire" between the keyboard and the main unit over the "classic" interfaces (XT,AT,PS/2,...). In any case, you won't ever see "scan codes" when talking about userspace applications on a modern OS.
The phenomenon of the XY-problem is not about using terms in a wrong way (and, "scan code" is often used wrong, so I just thought I'd add a short explanation what it really means for those interested ...), butI used the term 'scan code' because that is what I was used to saying many years ago with my original PS/2 keyboard.
about not mentioning THAT directly, which is, well, the actual problemI was simply trying to find out why FreeBSD knew what to do when I pressed Backspace and Emacs didn't.
You do not need to get used to only running it that way. The whole point of Emacs is that you bend it to your will. Just redefine the key to do whatever you want.Emacs is the problem! M-x describe-key shows 'C-h-' when Backspace is pressed.
I've just noticed that this only happens in text mode. If I run emacs -nw under X, I don't have a problem, so I need to get used to only running it that way.
I'm busy at the moment but have a look in sys/dev/kbd and sys/dev/atkbdc, you should be able to determine what scancode set FreeBSD sets.
options KBDIO_DEBUG=10
Sep 21 00:24:40 vmfbsd13 kernel: atkbd_read_char(): scancode:0x1e
Sep 21 00:24:40 vmfbsd13 kernel: atkbd_read_char(): scancode:0x9e
While this tool might be what is OP aiming for (legit answer then) it's not spitting out raw scancodes.misc/kbdscan is the right tool for that. It works only in console.
Sep 21 20:57:09 vmfbsd13 kernel: atkbd_read_char(): scancode:0xe0
Sep 21 20:57:09 vmfbsd13 kernel: atkbd_read_char(): scancode:0x48
Sep 21 20:57:09 vmfbsd13 kernel: atkbd_read_char(): scancode:0xe0
Sep 21 20:57:09 vmfbsd13 kernel: atkbd_read_char(): scancode:0xc8
Scancode 95 pressed.
Scancode 95 released.