I have this program in C that reads the input like this:
cod1 = getch ();
if (kbhit())
cod2 = getch ();
I can read every Ctrl+Char possible sequences, except for Ctrl+C, that closes the program – that is OK, and Ctrl+S, that simple is not catch. But I wanted to make Ctrl+S to be the save function in my program; how could I do that? Furthermore, is it possible to read Alt+Char characters? Because it reads it as a regular character, e.g., Alt+A is read with the same codes as A.
Your problem is that input probably gets eaten by terminal emulator.
For example
Alt+<Whatever>is often reserved for menu shortcuts (e.g.Alt+FopensFilemenu). Matching characters are often hilighted once you holdAlt(Fget’s underscored inFile).Ctrl+Sis reserved forStops all output on screen (XOFF)(again your terminal emulator does that).As for using
Alt+<...>as shortcuts in your command line application. As far as I’m concerned holdingAltdoesn’t affect character received, it just sets flags which are hard to access in console. Even in GUI application (in Windows) it’s quite tricky and you have to use function likeGetAsyncState()to check whether alt was pressed.