Detecting control codes - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Detecting control codes

WeirdofreakWeirdofreak Posts: 439Member
Assuming that the control codes for characters such as the cursor keys and F* (decimal 27 followed by 1-4 other numbers, or none for escape) are standard across POSIX-compliant systems, how would I detect one? I can do a test for 27 and then get more of them until I find a code I recognise, but then if I wanted Escape to be recognised I wouldn't be able to tell (ESC)[A from uparrow. I also wouldn't be able to easily tell when to assume that the code is to be printed.

This is more hypothetical than anything else, because I don't really need anything except the cursors and home/end/insert/delete, but I might want some others in the future.
Sign In or Register to comment.