I have a problem with NCurses... i need to handle all keys like Esc, Alt+F etc. Problem is that the codes are similar... i.e:
Esc - 27
Alt+A - 27 65
As an example there is double code for Alt+[key] combination what similar to Esc key... Any ideas how handle that?
Resolved by:
Here is an example for python:
key = self.screen.getch()
if key == ord('q'): # quit
go = False
elif key == 27: # Esc or Alt
# Don't wait for another key
# If it was Alt then curses has already sent the other key
# otherwise -1 is sent (Escape)
self.screen.nodelay(True)
n = self.screen.getch()
if n == -1:
# Escape was pressed
go = False
# Return to delay
self.screen.nodelay(False)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With