Results 1 to 4 of 4
Hi Friends!!
I am developing a command-line user interface in C using readline, and I have to add a function so that when the user press a shortcut, one editor ...
- 12-07-2011 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 72
get ctrl + key in C
Hi Friends!!
I am developing a command-line user interface in C using readline, and I have to add a function so that when the user press a shortcut, one editor is opened.
The problem is that I don't know how to get a ctrl + key in C, for example ctrl + s.
Is there anyway to get these shorcuts in C??
Thank you very much!!
- 12-08-2011 #2Linux User
- Join Date
- Jan 2005
- Location
- Saint Paul, MN
- Posts
- 262
The problem is that some of the control keys are grabbed by the pty (or tty). The control-s is grabbed to "stop/pause" output from stdout/stderr until the control-q is pressed to "resume" output. Some control keys sent signals to the process such as control-z, control-c, control-\, etc. If you are using a "GUI desktop" such as Gnome, KDE, etc, they can also grab several control keys as well.
- 12-09-2011 #3
You can look into "man termios", and in particular, canonical mode. This is (as I understand it) what shells do in order to support grabbing the tab character immediately, for instance. Note that this does disable any sort of line editing, unless you can configure anything with readline directly (I know nothing about readline).
Looking into readline a bit more, you may be able to bind your key directly in readline:
http://cnswww.cns.cwru.edu/php/chet/...ine.html#SEC32DISTRO=Arch
Registered Linux User #388732
- 12-09-2011 #4Just Joined!
- Join Date
- Nov 2009
- Posts
- 72
Hi friends!! thank you all very much!!!
I found the solution by myself. All I have to do is call to
Which will launch myfunction when ctrl + e is pressed.Code:rl_bind_key(0x05,myfunction); // ctrl+e will launch myfunction


Reply With Quote