Alternate ways to stop print() in python

Viewed 50

I have to get user input from the console. Using python input() statement only stops and returns the input when the user clicks "ENTER". But I want it to also happen with "TAB".

Is there a way that python input() can respond to both "ENTER" and "TAB" and return the user input?

I have tried different modules like msvcrt, keyboard, pynput, etc., But they simply read characters one by one. I had to deal with the below items:

  • Shift + ch (for uppercase)
  • Inserting characters in between (using right/left arrows)
  • Copy and Paste
  • Insert, etc

So I don't want to manually code for all these and many unknowns may raise in the future. These are all already taken care by python input(). I just need to stop it and return the output for "TAB" as well.

Please let me know if there is a way to achieve this. It might be helpful to a lot of users.

0 Answers
Related