2022-06-21 17:57:57 So is there any way in gcc to detect whether a key on the keyboard (any key will do) is up or down? 2022-06-21 17:58:22 This is something that was straightforward back in the old days, but I've never been able to find it in Linux. 2022-06-21 17:58:57 A shift key would be perfect. 2022-06-21 18:15:00 Ok, there must be a way, because the utility showkey detects press and release events. 2022-06-21 18:15:06 I need to find the source code for that. 2022-06-21 18:43:36 Oh, there's a python module called "keyboard" that looks like it can do what I want. 2022-06-21 18:44:24 Well, some of it, at least. 2022-06-21 18:46:59 Oh, yes - that will do: 2022-06-21 18:47:03 >>> print(keyboard.is_pressed('shift')) 2022-06-21 18:47:05 False 2022-06-21 18:47:07 >>> print(keyboard.is_pressed('shift')) 2022-06-21 18:47:09 True 2022-06-21 18:47:31 I'm wanting to write a Morse code entry utility, like I did back in the 90's. 2022-06-21 18:47:48 I can put that in a loop and time the events and that's sufficient. 2022-06-21 18:49:34 Only works if I run it as root, though. 2022-06-21 19:39:54 raw mode in the tty is the closest thing I know of that doesn't need root 2022-06-21 20:27:41 KipIngram: i think for keyboard events in userland, you might need something like sdl to get the events... afaik, the vt100 model that the linux terminal is based on just doesn't get separate keyup/keydown events 2022-06-21 20:27:55 but it *can* get mouseup/mousedown events... 2022-06-21 20:28:23 so if you're willing to use a mouse button, that might work with stdin in raw mode.