def handle_keypress(screen):
global selected_pid<EOL>try:<EOL><INDENT>key = screen.getkey().upper()<EOL><DEDENT>except:<EOL><INDENT>return<EOL><DEDENT>if key in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>move_selection()<EOL><DEDENT>elif key in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>move_selection(reverse=True)<EOL><DEDENT>elif key in ("<STR_LIT:A>", "<STR_LIT:+>"):<EOL><INDENT>send_signal("<STR_LIT>")<EOL>if selected_pid in gunicorns:<EOL><INDENT>gunicorns[selected_pid]["<STR_LIT>"] = <NUM_LIT:0><EOL><DEDENT><DEDENT>elif key in ("<STR_LIT>", "<STR_LIT:->"):<EOL><INDENT>if selected_pid in gunicorns:<EOL><INDENT>if gunicorns[selected_pid]["<STR_LIT>"] != <NUM_LIT:1>:<EOL><INDENT>send_signal("<STR_LIT>")<EOL>gunicorns[selected_pid]["<STR_LIT>"] = <NUM_LIT:0><EOL><DEDENT><DEDENT><DEDENT>elif key in ("<STR_LIT:R>",):<EOL><INDENT>if selected_pid in gunicorns:<EOL><INDENT>send_signal("<STR_LIT>")<EOL>del gunicorns[selected_pid]<EOL>selected_pid = None<EOL><DEDENT><DEDENT>elif key in ("<STR_LIT:T>",):<EOL><INDENT>for pid in gunicorns.copy().keys():<EOL><INDENT>selected_pid = pid<EOL>send_signal("<STR_LIT>")<EOL>del gunicorns[selected_pid]<EOL>selected_pid = None<EOL><DEDENT><DEDENT>elif key in ("<STR_LIT:M>", "<STR_LIT:->"):<EOL><INDENT>if selected_pid in gunicorns:<EOL><INDENT>send_signal("<STR_LIT>")<EOL>del gunicorns[selected_pid]<EOL>selected_pid = None<EOL><DEDENT><DEDENT>elif key in ("<STR_LIT>",):<EOL><INDENT>raise KeyboardInterrupt<EOL><DEDENT>
Check for a key being pressed and handle it if applicable.