On Fri, Jul 12, 2024 at 02:53:36PM +0200, Robert Pluim wrote: > >>>>> On Fri, 12 Jul 2024 08:14:52 -0400, Pierre Rouleau said: > > Pierre> Hi all, > Pierre> Does Emacs already have a predicate function that can be used to check if > Pierre> the specified key sequence is valid for Emacs running in terminal mode? > > Not that I know of, but Emacs always has functionality I donʼt know of > :-) > > Pierre> For example, "C-;" is not accessible on Emacs running in terminal mode > Pierre> because this is not an ASCII control character. It's available for Emacs > Pierre> running in graphical environment, but not in terminal mode. > > Pierre> Is there something similar already available or one would simply wrap > Pierre> describe-key and catch the error to check? > > Iʼm in a terminal frame: > > (describe-key (kbd "C-;")) => > #("C-; is undefined" 0 3 (face help-key-binding font-lock-face help-key-binding)) > > which is exactly what you get in a GUI frame. > > I think the best you can do is bind the key. If itʼs available, it will work. OK, negatively speaking, on a terminal CTRL zeros bit 6 (counting from LSB, starting with 0) to reach the control codes 0..1f (hex). So it only makes sense with the character codes 40..5f hex (that's '@'..'_'). Everything else is probably GUIsh. Cheers -- t