def prompt_toolkit_key_to_vt100_key(key, application_mode=False):
application_mode_keys = {<EOL>Keys.Up: '<STR_LIT>',<EOL>Keys.Left: '<STR_LIT>',<EOL>Keys.Right: '<STR_LIT>',<EOL>Keys.Down: '<STR_LIT>',<EOL>}<EOL>if key == Keys.ControlJ:<EOL><INDENT>return '<STR_LIT:\r>'<EOL><DEDENT>if key == '<STR_LIT:\n>':<EOL><INDENT>return '<STR_LIT:\r>'<EOL><DEDENT>elif application_mode and key in application_mode_keys:<EOL><INDENT>return application_mode_keys.get(key)<EOL><DEDENT>else:<EOL><INDENT>return _PROMPT_TOOLKIT_KEY_TO_VT100.get(key, key)<EOL><DEDENT>
Turn a prompt toolkit key. (E.g Keys.ControlB) into a Vt100 key sequence.
(E.g. \x1b[A.)