Let’s make a simple keyboard racing game using Python. In the game, the participant clicks a pair of keys in quick succession and the program shows the total time taken by the racer to cover the distance.
As soon as you see ‘GO!’ on screen, start pressing the keys ‘z’ and ‘x’. A ‘*’ sign is shown for every metre covered. Pressing ‘z’ and ‘x’ once will be counted as 1 metre; targets is to cover 10 metres.
msvcrt : Used to get keystroke as input for race time : Used to calculate time taken to complete the race
Note that MSVCRT module can only function on a terminal window, not on a GUI program/IDE.
Below is the code:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Mouse and keyboard automation using Python
- Keyboard module in Python
- Python | Vkeyboard (virtual keyboard) in kivy
- Python VLC MediaPlayer – Enabling Keyboard Input
- PyQt5 QSpinBox - Checking if user can change value using keyboard or not
- PyQt5 QCalendarWidget -Grabbing Keyboard input
- PyQt5 QCalendarWidget - Releasing Grabbed Keyboard input
- PyQt5 QCalendarWidget - Keyboard Grabber Property
- PYGLET – Setting Exclusive Keyboard for Window
- Simple Multithreaded Download Manager in Python
- Create simple Blockchain using Python
- Python | Simple registration form using Tkinter
- Python | Simple GUI calculator using Tkinter
- Python | Program to implement simple FLAMES game
- Python | Simple FLAMES game using Tkinter
- Python | Simple calculator using Tkinter
- Python | Tkinter ttk.Checkbutton and comparison with simple Checkbutton
- Python | Make a simple window using kivy
- Python | Create simple animation for console-based application
- Python | Thresholding techniques using OpenCV | Set-1 (Simple Thresholding)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.