Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the keycode for control+z key in python?

Tags:

python

I want to send some modem AT commands using python code, and am wondering what is the keycode for the key combination control+z

Gath

like image 847
gath Avatar asked Sep 16 '09 07:09

gath


2 Answers

Key code? If you send AT commands you are probably sending strings with ascii text and control codes, right? Ctrl-Z is usually 26 (decimal). So chr(26) should work, or if it's a part of a string, '\x1a' as 26 decimal is 1A hex.

That said, Ctrl-Z is not usually a part of the AT command set... so if this doesn't help you, maybe you could explain more what you are trying to do and why you would need to send Ctrl-Z.

like image 69
Lennart Regebro Avatar answered Oct 21 '22 22:10

Lennart Regebro


I was using python3; none of these work for my problem and what I did was,

command_variable = chr(26)
ser.write(command_variable.encode('utf-8'))

this worked for me. you can concatenate it with any command.

like image 24
RAJANTHA OBEYSEKARA Avatar answered Oct 21 '22 22:10

RAJANTHA OBEYSEKARA