471,330 Members | 1,203 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

Recognizing the <enter> key

Hey guys,
I am new to Python and I was wondering how to get a program to recognize the <enter> key when a user hits it
thnx
Oct 6 '07 #1
2 20558
Hey guys,
I am new to Python and I was wondering how to get a program to recognize the <enter> key when a user hits it
thnx
use pygame and you have code for using keys ...or use this code with "Tkinter" module :
Expand|Select|Wrap|Line Numbers
  1. from Tkinter import *
  2.  
  3. root = Tk()
  4. def greet(*ignore): print 'Hello World'
  5. root.bind('<Return>', greet)
  6. root.mainloop()
Oct 6 '07 #2
bartonc
6,596 Expert 4TB
Hey guys,
I am new to Python and I was wondering how to get a program to recognize the <enter> key when a user hits it
thnx
Expand|Select|Wrap|Line Numbers
  1. raw_input('Press any key to continue')
  2. # run here after a key is pressed
  3.  
  4. # or #
  5.  
  6. key = "anything"
  7. while key != "":
  8.     key = raw_input('Hit <Enter> to continue')
Oct 7 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Denis Hierstein | last post: by
7 posts views Thread by jerrygarciuh | last post: by
7 posts views Thread by Susan Bricker | last post: by
2 posts views Thread by JP | last post: by
5 posts views Thread by DotNetGruven | last post: by
2 posts views Thread by Rocio | last post: by
reply views Thread by Tom Edelbrok | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.