1

the problem = I dont know how to get a program to detect a input from the keyboard without using IDLE

A solution to my problem would look like; some code so that when a key is pressed it sets/makes a variable. (I am doing this on a raspberry pi) eg. code code code 'user presses space bar' pi camera takes picture and ends the preview. I dont want it so that the input is in the python shell, just when the space bar is pressed. just to note I am a beginner coder who knows next to nothing so if you can help or point me in the right direction I would be grateful.

edit:

here is the code I have so far

from picamera import PiCamera 
from time import sleep
import webbrowser
#importing all the needed things
webbrowser.open('/home/pi/RyansScienceFair/test.html')
#opens a webbrowser that I coded
camera = PiCamera
camera.start_preview(alpha = 220)
sleep(10)
camera.stop_preview()
#runs the camera for 10 seconds with some transparency 

what I want is when the user is looking at the web page, which will be displayed under the camera display, they can press spacebar and then the program takes a photo and then ends the camera preview. I can do the camera capture and work out the end time for the camera but its the trigger that I cant figure out.

Ryan.B
  • 13
  • 5
  • please read this post, https://raspberrypi.stackexchange.com/questions/28302/python-script-with-loop-that-detects-keyboard-input – jits_on_moon Jul 19 '18 at 03:23
  • so the code that the guy who answered the question was waiting for a input from any of the listed buttons? how would I use this? – Ryan.B Jul 19 '18 at 04:26

0 Answers0