Ah I see I was too quickly to convert the codes into a char atom… basically I was able to get things working with
get_single_key_code(Code):- get_single_char(C),into_key_codes([C],Code).
into_key_codes([27],Codes):- get_single_char(C1),into_key_codes([27,C1],Codes).
into_key_codes([27,27],Codes):- get_single_char(C1),into_key_codes([27,27,C1],Codes).
into_key_codes([27,91],Codes):- get_single_char(C1),into_key_codes([27,91,C1],Codes).
into_key_codes([27,79],Codes):- get_single_char(C1),into_key_codes([27,79,C1],Codes).
into_key_codes([27,N1,54],Codes):- get_single_char(C1),into_key_codes([27,N1,54,C1],Codes).
into_key_codes([27,N1,53],Codes):- get_single_char(C1),into_key_codes([27,N1,53,C1],Codes).
into_key_codes(C,C).
% crl left arrow
do_menu_codes([27,79,68]):- !, previous_test, print_test.
% ctrl right arrow
do_menu_codes([27,79,67]):- !, next_test, print_test.
% alt left arrow
do_menu_codes([27,27,79,68]):- !, previous_test, print_test.
% alt right arrow
do_menu_codes([27,27,79,67]):- !, next_test.
% left arrow
do_menu_codes([27,91,68]):- !, previous_test.
% right arrow
do_menu_codes([27,91,67]):- !, next_test, print_test.
% page up
do_menu_codes([27,91,53,126]):- restart_suite
% page down
do_menu_codes([27,91,54,126]):- next_suite.