How I can capture in Python the Ctrl key (only Ctrl, without another at the same time) when pressed? -


i need detect, in python console (text mode) program, when ctrl key pressed, without key @ same time. tried getch curses library , stdin, waits key not ctrl or alt. found information in stackoverflow referred windows/event environment, or pressed simultaneously key (ctrl + c example) not case. have found in forum that's no possible, can believe it.

this answer linux-centric, seeing mention of raspbian console mode implies debian gnu/linux console system.

if you're talking console, possible albeit hacky. curses has raw mode read keys, control modifier key, won't show way. method can think of read input device, x would. use lsinput find device keyboard. input-events demonstrates, can see events there while processed elsewhere. among downsides won't know if input going (unless track virtual console switching, job status etc) , need access device, property implies might sensitive data such password being entered login on virtual console.

it might simpler remap control key sends using loadkeys, changing modifier detectable key. still retain lower level protocol properties (in usb hid boot protocol keyboard, instance, have dedicated bit rather use 1 of typically 6 slots pressed keys).

either way, not easy or portable, , won't work @ on terminal environments such ssh session.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -