On Sat, Oct 31, 2020 at 03:42:11PM -0400, Thomas George wrote: > I want to assign a unicode character to an unused key on my keyboard. For > example F6 currently is assigned ~, name of my home directory. I would like > to change it to ♠.
You are probably confused about what's actually happening. I imagine that you opened an X11 terminal window with a shell running in it, and pressed F6 without any prelude, and saw a ~ appear in the shell. If this is what you did, then you aren't really seeing what F6 does in a terminal. > I have tried xmodmap -e keycode 71 = U2660 and several other variations > without success As you know, F6 corresponds to a single keycode in X11. All well and good. However, in a *terminal emulator*, that keycode is translated into a stream of bytes. And the specific stream of bytes depends on the terminal emulator. Typically, function keys, arrow keys, and the like, will be translated to a sequence that begins with ESC [. The effect of this within your shell will depend on the shell, and what input/editing mode the shell is currently using. In your case, I imagine that the ESC [ and whatever follows it all get swallowed up (they attempt, perhaps, to perform some sort of editing manipulation on the empty shell input buffer), and all you see is the tilde character. But there are actually several other bytes before that. You just aren't seeing them. The usual hack to see what a key does in a terminal is to press Ctrl-V first, and then press the key in question. This relies on the special byte of the function key being up front, so that Ctrl-V can escape that byte. In xterm or in urxvt, when I press Ctrl-V F6, I see ^[[17~ The ^[ is a rendering of ESC ("escape"), the first byte of the key's translated byte stream. Altogether, F6 sends ESC [ 1 7 ~ in my terminals. This matches up with what one would expect from the terminfo database. unicorn:~$ infocmp xterm | grep f6 kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~, kf6 ("key function six") is defined as sending \E (ESC) [ 1 7 ~ The terminfo database is what applications use to try to guess what a given input sequence of bytes *means*. If you are trying to map F6 to a specific action within your shell (and if that shell is bash), you need to look at readline, ~/.inputrc, the bind command, etc. If on the other hand you'd prefer to do it at the X11 level, then look at xmodmap.