Recognizing the difference between certain key combinations like <tab>
and <ctrl+i>
in a Linux terminal can be tricky. This is because, historically, these key combinations are often mapped to the same ASCII control codes.
If you want to distinguish between these keys in a program, you can use libraries that provide lower-level access to the input, like ncurses
for C/C++ or similar libraries in other languages. These libraries can sometimes discern the difference between key combinations by capturing the raw keycodes.
Here is a simple example using C and ncurses
:
c#include <ncurses.h> int main() { initscr(); raw(); // Disable line buffering keypad(stdscr, TRUE); // Enable special keys noecho(); // Don't echo the characters printw("Press any key to see its code or 'q' to quit\n"); int ch; while(1) { ch = getch(); if(ch == 'q') break; // Clear line and print keycode move(1, 0); clrtoeol(); printw("Keycode: %d", ch); refresh(); } endwin(); return 0; }
bashgcc your_file.c -lncurses
Run the compiled program in the terminal and press keys to see if it can distinguish them.
Note: This may not work for all key combinations due to terminal limitations and configurations.
with friendly greetings
Knud van Eeden
-----You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/semware/CA%2BgEvka6FeeL3UGDx5K-x34k4-35aXG_WCDqTR-gdjMV9xBMGQ%40mail.gmail.com.