kiloleader
Posts: 10
Joined: Tue Oct 14, 2014 9:02 am

Setting up your own keyboard interrupts

Tue Nov 25, 2014 4:51 pm

Hi all,

I have a script (to run at start-up) that listens for incoming IR pulses or button interrupts. Part of the code uses the Ctrl C keyboard interrupt to interrupt the listening and allow me to type messages into the program. I have tested this in idle with no problems, but when I make it run at boot (by editing /etc/rc.local ) the Ctrl C interrupt no longer works. Is there a way to create your own keyboard interrupt for, say, the Enter key?

The code is quite large, but the relevant bit looks like:

interrupt = False
while True:
try:
listen_for_IR()
if interrupt:
interrupt = False
* Do some stuff *
except KeyboardInterrupt:
interrupt = True
except:
print "error"
* Error handling*

Any thoughts?

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Setting up your own keyboard interrupts

Tue Nov 25, 2014 8:07 pm

Is this Python?
Please put your code in [/b] blocks to make it readable...

Gr.
Dirk.

Return to “Python”