I am preparing a very simple script and I need the user to input certain values. At a certain point, I want to offer the chance to reuse an existing value or delete it if the user input is the DELETE key (the user presses DELETE and then Enter) but I don't seem to be able to find a satisfactory answer (which I find rather surprising...) It's just a helper script, so I was trying to avoid more advanced stuff such as PyHook and things like that.
This is the chunk I'm interested in:
if reusable_params:
for key in list(k for k in config_dict.keys() if k not in ["mac", "base_url", "command_name"]):
msg = "Enter new value for parameter {0}. Press ENTER to reuse the previous {1}. Press DELETE+ENTER to remove this key.".format(key, config_dict[key])
input = unicode(raw_input(msg).strip().decode(sys.stdin.encoding))
logging.debug("input: %s, len(input) %s" % (input, len(input))
Pressing DELETE+Enter returns a unicode looking 4 characters string:
Thank you in advance!