I’m using raw_input in Python to interact with user in shell.
c = raw_input('Press s or n to continue:')
if c.upper() == 'S':
print 'YES'
It works as intended, but the user has to press enter in the shell after pressing ‘s’. Is there a way to accomplish what I need from an user input without needing to press enter in the shell? I’m using *nixes machines.
Under Windows, you need the
msvcrtmodule, specifically, it seems from the way you describe your problem, the function msvcrt.getch:(etc — see the docs I just pointed to). For Unix, see e.g. this recipe for a simple way to build a similar
getchfunction (see also several alternatives &c in the comment thread of that recipe).