dersoi
dersoi

Reputation: 127

Ctrl + two chars


I'm working on a python script to send data on a com port. The problem is, I need to send Ctrl+p+p (so on a keyboard, I'd stay on the Ctrl button and type twice the 'p' char), but I can't find a way to do this. I use the pyserial library.

Upvotes: 2

Views: 287

Answers (1)

JohanL
JohanL

Reputation: 6891

Looking in an ascii table, e.g. this, you will see that ctrl+p is mapped to 0x10. Thus, for your script to transmit ctrl+p, you need to transmit 0x10.

Then transmitting ctrl+p+p (holding ctrl) is just the same value twice. Your script should therefore transmit 0x10 0x10 in sequence.

Upvotes: 4

Related Questions