moved the process_key_event function in a dedicated file for further factorization