Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #228401 > unrolled thread

Special Key Assignment?

Started byThomas George <lists@tomgeorge.info>
First post2020-10-31 20:50 +0100
Last post2020-11-04 20:50 +0100
Articles 6 — 4 participants

Back to article view | Back to linux.debian.user


Contents

  Special Key Assignment? Thomas George <lists@tomgeorge.info> - 2020-10-31 20:50 +0100
    Re: Special Key Assignment? The Wanderer <wanderer@fastmail.fm> - 2020-10-31 21:30 +0100
      Re: Special Key Assignment? Linux-Fan <Ma_Sys.ma@web.de> - 2020-10-31 22:30 +0100
      Re: Special Key Assignment? Success Thomas George <lists@tomgeorge.info> - 2020-10-31 22:40 +0100
    Re: Special Key Assignment? Greg Wooledge <wooledg@eeg.ccf.org> - 2020-11-02 14:30 +0100
      Re: Special Key Assignment? Thomas George <lists@tomgeorge.info> - 2020-11-04 20:50 +0100

#228401 — Special Key Assignment?

FromThomas George <lists@tomgeorge.info>
Date2020-10-31 20:50 +0100
SubjectSpecial Key Assignment?
Message-ID<B652W-3mS-7@gated-at.bofh.it>
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 ♠.

I have  tried xmodmap -e keycode 71 = U2660 and several other variations 
without success

[toc] | [next] | [standalone]


#228402

FromThe Wanderer <wanderer@fastmail.fm>
Date2020-10-31 21:30 +0100
Message-ID<B65FE-3OK-5@gated-at.bofh.it>
In reply to#228401

[Multipart message — attachments visible in raw view] — view raw

On 2020-10-31 at 15:42, 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 ♠.
> 
> I have  tried xmodmap -e keycode 71 = U2660 and several other variations 
> without success

Looking at the EXAMPLES section of the xmodmap man page, I see only a
few examples of command-line invocation using '-e', and all of them
have the expression in quotes. Based on that, the first thing I'd
suggest would be:

# xmodmap -e "keycode 71 = U2660"

Was that one of the variations you tried?


The second thing - have you verified that F6 is keycode 71? On my
computer (according to a test just now with xev), it's 72, and keycode
71 is F5.


(I haven't tried remapping this myself, as I don't know offhand how to
reverse it and I don't have a discardable test environment on hand, so I
can't testify as to whether these work for me.)

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

[toc] | [prev] | [next] | [standalone]


#228403

FromLinux-Fan <Ma_Sys.ma@web.de>
Date2020-10-31 22:30 +0100
Message-ID<B66BH-4na-5@gated-at.bofh.it>
In reply to#228402

[Multipart message — attachments visible in raw view] — view raw

The Wanderer writes:

> On 2020-10-31 at 15:42, 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 ♠.

[...]

> # xmodmap -e "keycode 71 = U2660"

[...]

> (I haven't tried remapping this myself, as I don't know offhand how to
> reverse it and I don't have a discardable test environment on hand, so I
> can't testify as to whether these work for me.)

[...]

I just tried it in a VM and got the results The Wanderer suggested:

The following inputs ♠ upon pressing [F5]

	xmodmap -e "keycode 71 = U2660"

The following inputs ♠ upon pressing [F6]

	xmodmap -e "keycode 72 = U2660"

HTH
Linux-Fan

[toc] | [prev] | [next] | [standalone]


#228404 — Re: Special Key Assignment? Success

FromThomas George <lists@tomgeorge.info>
Date2020-10-31 22:40 +0100
SubjectRe: Special Key Assignment? Success
Message-ID<B66Ln-4qh-1@gated-at.bofh.it>
In reply to#228402
I had not tried putting the expression in quotes. When I did it worked.

Of course keycodes may differ for different systems and different 
keyboards. With mine xmodmap -pk showed 71 as keycode for F5.

On 10/31/20 4:23 PM, The Wanderer wrote:
> On 2020-10-31 at 15:42, 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 ♠.
>>
>> I have  tried xmodmap -e keycode 71 = U2660 and several other variations
>> without success
> Looking at the EXAMPLES section of the xmodmap man page, I see only a
> few examples of command-line invocation using '-e', and all of them
> have the expression in quotes. Based on that, the first thing I'd
> suggest would be:
>
> # xmodmap -e "keycode 71 = U2660"
>
> Was that one of the variations you tried?
>
>
> The second thing - have you verified that F6 is keycode 71? On my
> computer (according to a test just now with xev), it's 72, and keycode
> 71 is F5.
>
>
> (I haven't tried remapping this myself, as I don't know offhand how to
> reverse it and I don't have a discardable test environment on hand, so I
> can't testify as to whether these work for me.)
>

[toc] | [prev] | [next] | [standalone]


#228432

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2020-11-02 14:30 +0100
Message-ID<B6I4h-4Br-9@gated-at.bofh.it>
In reply to#228401
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.

[toc] | [prev] | [next] | [standalone]


#228464

FromThomas George <lists@tomgeorge.info>
Date2020-11-04 20:50 +0100
Message-ID<B7wX8-2Z3-17@gated-at.bofh.it>
In reply to#228432
Thanks, Greg, I am clearly exploring territory I don't fully understand.

cd F5 displays as cd ~ and takes me to my home directory if entered.

xmodmap -e "keycode 71 = U2660 U2664 U2665 U2667" changes F5 to the 
unicode spade symbol as seen below. shift F5  produces the outline spade 
symbol. I have not found any modifier key of F5 for the final two unicodes.

This change of the F5 key works in terminals, in LibreOffice Writer, and 
in emails.

Even so it is really not a good idea. For example, it blocks the use of 
F5 in Idle.

Perhaps there are better choices. There are some strange keys on the 
Logitech keyboard that I never have had occasion to use. My need is not 
urgent, just curiosity.

On 11/2/20 8:25 AM, Greg Wooledge wrote:
> 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.
>
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web