Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to time a user's input
Hello again!

For a text-based game I am making, combat is an essential part. I have chosen to make a timed system, where the quicker you press a certain key the more damage you do. Obviously you can use the input command, however there is no way you can time that, as the user stops moving through the code until a key is pressed. If anyone knows a way to do this, I would greatly appreciate it. Thanks!
imho, the main problem with input is that you need to pres Enter. so basically you need to explore the ways to read key pressed. this will depend on the OS.
otherwise the solution is simple - get before and after time and calculate the difference
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

as buran explained you need to control hotkeys on the keyboard.
Take a look at this package:
github code location:
specifically this part:
Quote:Complex hotkey support (e.g. ctrl+shift+m, ctrl+space) with controllable timeout.

There are other packages, see:

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to access the user input value given to daterangepicker klllmmm 1 485 May-26-2021, 09:16 PM
Last Post: nilamo
  Problem restricting user input in my rock paper scissors game ashergreen 6 903 Mar-25-2021, 03:54 AM
Last Post: deanhystad
  LinkedList by User Input SantiagoPB 5 971 Mar-03-2021, 09:54 PM
Last Post: deanhystad
  User input/picking from a list AnunnakiKungFu 2 551 Feb-27-2021, 12:10 AM
Last Post: BashBedlam
  Generate Random operator, take user input and validate the user mapypy 4 607 Feb-03-2021, 08:41 PM
Last Post: nilamo
  Loop back through loop based on user input, keeping previous changes loop made? hbkpancakes 2 918 Nov-21-2020, 02:35 AM
Last Post: hbkpancakes
  user input for multi-dimentional list without a prior iteration using input() Parshaw 6 858 Sep-22-2020, 04:46 PM
Last Post: Parshaw
  converting user input to float troubles RecklessTechGuy 3 828 Aug-17-2020, 12:41 PM
Last Post: deanhystad
  Validating user input WJSwan 2 792 Jul-06-2020, 07:21 AM
Last Post: menator01
  Hi, I need help with defining user's input and applying it to code. jlmorenoc 2 754 Jun-24-2020, 02:10 PM
Last Post: pyzyx3qwerty

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020