Actually in the meantime (almost 10 years from the start of this thread) a cross-platform module named pynput appeared. Below a first cut - i.e. that works with lowercase 's' only. I have tested it on Windows but I am almost 100% positive that it should work on Linux.

from pynput import keyboard

print('Press s or n to continue:')

with keyboard.Events() as events:
    # Block for as much as possible
    event = events.get(1e6)
    if event.key == keyboard.KeyCode.from_char('s'):
        print("YES")
Answer from Adrian Rosoga on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › python input function without pressing enter?
r/learnpython on Reddit: Python input function without pressing enter?
December 19, 2020 -

Howdy,

Do you know if there is a way to accept user's input without pressing enter?

I am trying to exit a while loop by pressing the key "q" but with the input() function I have to press enter.

I would like to use standard Python modules (if possible) and not install anything else with pip.

Thank you!

Edit: I'm using Python3.8 on Unix

Discussions

Jupyter Python Script waiting keyboard input without Enter strike
Dear Friends, My script wants to get the input from the keyboard without the need of hitting the ENTER key. The input() function works for getting the input, but it requires hitting the enter key. I have also tried several libraries for being used in .py scripts, but none of them works in ... More on discourse.jupyter.org
🌐 discourse.jupyter.org
2
0
June 3, 2022
Get input without pressing enter
My previous answer overlooked that you needed it w/o pressing enter. The problem with this is that there's a mediator between your program and the user input, namely, the terminal. Terminal in default configuration sends full lines, not characters. This is actually not fully dependent on the terminal, it does it in cooperation with the operating system, at least on Linux. It is possible, however, to configure both into switching to the character mode. Here's an example with curses: import curses def getch(): screen = curses.initscr() print(screen.getch()) getch() There are few other libraries that can do this, however curses is shipped with Python, usually. More on reddit.com
🌐 r/learnpython
3
3
November 19, 2021
while loop - How to accept input without the need to press enter Python 3 - Stack Overflow
i'm wondering how to accept input without the need to press enter. i searched online, and i get something regarding raw_input, but i think that became obsolete after the arrival of python 3.0. some... More on stackoverflow.com
🌐 stackoverflow.com
December 30, 2013
What's a python function that reads any keyboard pressed, without pressing enter after it?

You can also use https://pypi.org/project/pynput/

More on reddit.com
🌐 r/learnpython
11
6
July 18, 2019
🌐
Quora
quora.com › How-can-I-give-input-without-pressing-enter-key-in-Python
How to give input without pressing enter key in Python - Quora
Answer (1 of 2): Whenever we take input to any program we needed to press enter , whether we are talking about any of the languages but they provide us any such type of command that helps us to take input without pressing enter key. for eg: in c we can use getch() , and in Python also we can us...
🌐
Wordpress
paulcrickard.wordpress.com › 2013 › 05 › 03 › user-input-in-python-without-pressing-enter
User Input in Python Without Pressing Enter | Architecture and Planning
May 3, 2013 - The other thing I learned on this is that in python While has an Else. The while loops took me a few tries to figure out but I am awful at control structures. ... d=”.join(a) d=d.strip(‘\t’) inputs=”SN”+d sql=”SELECT term FROM terminals WHERE id='”+inputs+”‘” for row in cursor.execute(sql): print row[0] input_char=” d=” a=[] break
🌐
Sololearn
sololearn.com › en › Discuss › 2462337 › is-it-possible-to-take-input-without-clicking-on-enter-key-in-python
Is it possible to take input without clicking on ENTER key in python? | Sololearn: Learn to code for FREE!
August 25, 2020 - This is the one: https://stackoverflow.com/questions/1335507/keyboard-input-with-timeout It's python2, just add parenthesis to print() 25th Aug 2020, 7:11 AM · Aymane Boukrouh · + 5 · Kode Krasher that's why I never post codes on SoloLearn ;) 25th Aug 2020, 7:16 AM · Aymane Boukrouh · + 3 · “input without entering” Does that mean that you just declare a variable with a string?
🌐
DaniWeb
daniweb.com › programming › software-development › code › 238746 › getting-an-input-without-hitting-enter
python - Getting an input without hitting enter | DaniWeb
November 16, 2009 - Getting user's input without hitting "Enter" (msvcrt.getch()) 1 · Getting user input with special characters 6 · Recursively printing words 2 · Getting information from web page with Python 31 · Reading from piped stdin with read()? 1 · How to input two integers in Python 3 ·
🌐
GitHub
gist.github.com › shaperilio › 1b9065b149944d060a4da33d7bf6b78b
Python 3 key input without enter key · GitHub
Python 3 key input without enter key. GitHub Gist: instantly share code, notes, and snippets.
Find elsewhere
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › programming › python
Entering digits without pressing "Enter' - Raspberry Pi Forums
This topic has come up many times, but it is difficult to search for unless you already know that the traditional name for a function that reads a single input character without line buffering is getch(). My version in a post over ten years ago: viewtopic.php?t=69046#p502895 Python 3 is smart enough to always read a full character, rather than just one byte, in a modern .UTF-8 locale.
🌐
Sololearn
sololearn.com › en › Discuss › 170586 › how-could-i-use-input-without-i-have-to-enter-the-result-
How could I use input() without I have to enter the result ? | Sololearn: Learn to code for FREE!
OK try this while True: try: x=int(input("enter x")) #what you want to do print("you entered"+str(x)) #im doing it except keyboardinterpreterror: break it will ask you input every time and will return print data and if you press any key on keyboard it will stop ... Sun I'm sure that could work but unfortunately my python don't know keyboardinterpreterror..
🌐
CodeRivers
coderivers.org › blog › get-input-without-enter-python
Getting Input Without Enter in Python - CodeRivers
March 18, 2025 - The msvcrt module in Python provides functions that interact with the Microsoft Visual C Runtime Library. The getch() function within this module can be used to read a single character from the console without waiting for the Enter key to be pressed. This is possible because it directly accesses ...
🌐
Replit
replit.com › talk › ask › Python-How-do-I-input-without-pressing-enter › 33815
[Python] How do I input without pressing enter
This way, you can share your code without giving other users access to your personal data or linked accounts. ... Web pages written in HTML, CSS, and JavaScript can be deployed on Replit. HTML/CSS/JS repls are given a unique URL that can be shared with your friends, family, peers, and clients. ... Replit will install most available Python ...
🌐
Reddit
reddit.com › r/learnpython › what's a python function that reads any keyboard pressed, without pressing enter after it?
r/learnpython on Reddit: What's a python function that reads any keyboard pressed, without pressing enter after it?
July 18, 2019 -

input() memorizes the key you press only if you also press enter after it. I'm trying to make a CLI game and I looked up on how I could get the keyboard input and found this answer on stackoverflow explaining something about multi-threaded input which is just what i needed (the third answer here https://stackoverflow.com/questions/5404068/how-to-read-keyboard-input)

however, while it is true that it's multi-threaded and it doesn't stop the program for you to enter the input, for your input to be memorized in the inputQueue you also need to press enter after entering a key. Is there a function that memorizes your input without pressing enter, just memorizes the first key you press? So that I could replace the input() in the following function with that method

def read_kbd_input(inputQueue):
    print('Ready for keyboard input:')
    while (True):
        input_str = input()  ##replace here ## 
        inputQueue.put(input_str)
🌐
LinuxQuestions.org
linuxquestions.org › questions › programming-9 › python-how-to-process-console-input-without-newline-4175630087
[SOLVED] Python - how to process console input without newline?
May 20, 2018 - I need to process console input but it does not include any end-of-line indication. The application is a remote control for an entertainment system