Remap an arbitrary key on keyboard to another output
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Remap an arbitrary key on keyboard to another output
I have a calculator key on my new laptop, right next to the control key. My muscle memory from my old keyboard keeps hitting calculator key instead of the control. Until I find a compelling use for the key I'd ideally like to have it as an additional control. Hopefully having multiple keys doing the same thing on the keyboard is possible?
I'm asking how to change any key on the keyboard to another because there's a few other changes I'd like to make in the future (there's a few other shortcut keys besides calculator). I need to know how to set this up this change permanently and reversibly (in case something goes terribly wrong)
I am a complete newbie and would prefer it explained like I'm five. However, if one of the steps ends up being "go read this tutorial on editing these kinds of configuration files," that would be fine too--I installed Linux in part to learn how to configure arbitrary things about my computer.
edit: Changed "Change" in subject to remap, per further googling. Still hoping for step-by-step instructions, however. "xmodmap" looks like something I'll have to use?
I'm asking how to change any key on the keyboard to another because there's a few other changes I'd like to make in the future (there's a few other shortcut keys besides calculator). I need to know how to set this up this change permanently and reversibly (in case something goes terribly wrong)
I am a complete newbie and would prefer it explained like I'm five. However, if one of the steps ends up being "go read this tutorial on editing these kinds of configuration files," that would be fine too--I installed Linux in part to learn how to configure arbitrary things about my computer.
edit: Changed "Change" in subject to remap, per further googling. Still hoping for step-by-step instructions, however. "xmodmap" looks like something I'll have to use?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Remap an arbitrary key on keyboard to another output
Not sure if you're running the gnome DEs but in KDE there are settings under System Settings -> Hardware -> Input Devices -> Keyboard where you can change keyboard models, layouts (including shortcuts for switching layout, and configure keyboard options. Maybe this will help.
Re: Remap an arbitrary key on keyboard to another output
I'm pretty sure I'm running Mate. I don't quite remember what I ended up installing, what's the quick and dirty way to check? (I have a program called eye of mate, which is why I'm guessing I have Mate installed).Jaws wrote:Not sure if you're running the gnome DEs but in KDE there are settings under System Settings -> Hardware -> Input Devices -> Keyboard where you can change keyboard models, layouts (including shortcuts for switching layout, and configure keyboard options. Maybe this will help.
Re: Remap an arbitrary key on keyboard to another output
I think I'm making progress, I found http://askubuntu.com/questions/24916/ho ... rtain-keys to be pretty much what I'm looking for.
Using xev, here is the output for "ctrl" and then, immediately after, "calc":
...the output for the calc key is really confusing to me. I'm not sure how that would fit into the xmodmap editing instructions that are listed in the link apply to the output I actually got.
edit: updated pasted xev output to a possibly more relevant snippet. Seems to be double-reporting keypresses in the output?
Using xev, here is the output for "ctrl" and then, immediately after, "calc":
Code: Select all
KeyPress event, serial 33, synthetic NO, window 0x3600001,
root 0xaf, subw 0x0, time 79820428, (374,-425), root:(377,82),
state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 33, synthetic NO, window 0x3600001,
root 0xaf, subw 0x0, time 79820533, (374,-425), root:(377,82),
state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
FocusOut event, serial 33, synthetic NO, window 0x3600001,
mode NotifyGrab, detail NotifyAncestor
FocusIn event, serial 33, synthetic NO, window 0x3600001,
mode NotifyUngrab, detail NotifyAncestor
KeymapNotify event, serial 33, synthetic NO, window 0x0,
keys: 4294967265 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FocusOut event, serial 33, synthetic NO, window 0x3600001,
mode NotifyNormal, detail NotifyNonlinear
edit: updated pasted xev output to a possibly more relevant snippet. Seems to be double-reporting keypresses in the output?
Re: Remap an arbitrary key on keyboard to another output
This is not what he's searching for.
It's very easy to achieve what you ask for.
First thing you need to know is the key code for the special key you want to configure, to achieve that write in a terminal:
a small window will open and since then every key you press, or movement of mouse is recorded and print on terminal, so don't move mouse a press the key you are interested to know the code, and suddenly some values will appear in the terminal window. The one you are interested in is key code. Keep in mind that value or write it down somewhere.
Now write in terminal:
Then:
If your keycode instead is not there in the list it means that the key is not mapped in the layout you choose, so try to add the line you need, something like:
keycode XX = Control_L NoSymbol Control_L NoSymbol Control_L
where "XX" is the key code you previously wrote down.
Save it by pressing Ctrl+o and exit by pressing Ctrl+x.
Now write in the terminal:
If it works fine you should in the end write a small script to execute at startup, so that you will have your key mapped every time you start your machine up.
Write in a terminal:
save the file and exit.
Last thing to do is to write in terminal:
it should work, however if it doesn't we could try to understand what's the matter.
I hope it's enough "5yrs old style"
It's very easy to achieve what you ask for.
First thing you need to know is the key code for the special key you want to configure, to achieve that write in a terminal:
xev
a small window will open and since then every key you press, or movement of mouse is recorded and print on terminal, so don't move mouse a press the key you are interested to know the code, and suddenly some values will appear in the terminal window. The one you are interested in is key code. Keep in mind that value or write it down somewhere.
Now write in terminal:
and press Enter.xmodmap -pke > $HOME/.keymap.conf
Then:
search for the key code you previously wrote down, and write after the "=" :sudo nano $HOME/.keymap.conf
Code: Select all
Control_L NoSymbol Control_L NoSymbol Control_L
If your keycode instead is not there in the list it means that the key is not mapped in the layout you choose, so try to add the line you need, something like:
keycode XX = Control_L NoSymbol Control_L NoSymbol Control_L
where "XX" is the key code you previously wrote down.
Save it by pressing Ctrl+o and exit by pressing Ctrl+x.
Now write in the terminal:
And check if your special key acts like Ctrl.xmodmap $HOME/.keymap.conf
If it works fine you should in the end write a small script to execute at startup, so that you will have your key mapped every time you start your machine up.
Write in a terminal:
and copy inside the empty file modifying "user" with your account name:sudo nano /etc/init.d/keymap.sh
Code: Select all
#!/bin/sh
PATH=/home/"user"/.keymap.conf
#Execute key re-mapping
xmodmap $PATH
Last thing to do is to write in terminal:
Reboot machine and praysudo update-rc.d keymap.sh defaults
it should work, however if it doesn't we could try to understand what's the matter.
I hope it's enough "5yrs old style"
Re: Remap an arbitrary key on keyboard to another output
Code: Select all
KeymapNotify event, serial 33, synthetic NO, window 0x0,
keys: 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FocusOut event, serial 33, synthetic NO, window 0x3600001,
mode NotifyGrab, detail NotifyAncestor
FocusIn event, serial 33, synthetic NO, window 0x3600001,
mode NotifyUngrab, detail NotifyAncestor
KeymapNotify event, serial 33, synthetic NO, window 0x0,
keys: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FocusOut event, serial 33, synthetic NO, window 0x3600001,
mode NotifyNormal, detail NotifyNonlinear
Using xev, I can get other keys to give key codes, even from that same row of proprietary keys, but the calculator key doesn't?
when I try the key right above it, a printer key, I get something completely different:
Code: Select all
KeyPress event, serial 33, synthetic NO, window 0x3600001,
root 0xaf, subw 0x0, time 57835909, (56,-17), root:(59,53),
state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 33, synthetic NO, window 0x3600001,
root 0xaf, subw 0x0, time 57835910, (56,-17), root:(59,53),
state 0x4, keycode 33 (keysym 0x70, p), same_screen YES,
XLookupString gives 1 bytes: (10) ""
XmbLookupString gives 1 bytes: (10) ""
XFilterEvent returns: False
KeyRelease event, serial 33, synthetic NO, window 0x3600001,
root 0xaf, subw 0x0, time 57836047, (56,-17), root:(59,53),
state 0x4, keycode 33 (keysym 0x70, p), same_screen YES,
XLookupString gives 1 bytes: (10) ""
XFilterEvent returns: False
KeyRelease event, serial 33, synthetic NO, window 0x3600001,
root 0xaf, subw 0x0, time 57836050, (56,-17), root:(59,53),
state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
Verify that this is a valid command."
So I went and installed gcalctool, the key now launches the calculator, and using xev gets me this readout:
Code: Select all
VisibilityNotify event, serial 33, synthetic NO, window 0x3600001,
state VisibilityPartiallyObscured
FocusOut event, serial 33, synthetic NO, window 0x3600001,
mode NotifyNormal, detail NotifyNonlinear
PropertyNotify event, serial 33, synthetic NO, window 0x3600001,
atom 0x186 (_NET_WM_ICON_GEOMETRY), time 58314031, state PropertyNewValue
Re: Remap an arbitrary key on keyboard to another output
A single bump. I am so close it hurts! But not quite there yet.
Re: Remap an arbitrary key on keyboard to another output
Hi guys, I hope someone still sees this as it's an old post. I originally put this on the newbies section but it was suggested that it was possibly a bit much for there, so hopefully it'll work better here. Anyway, I've been following the instructions for remapping and it's all working well but I'm struggling to get the keymappings to stick after I reboot.
The problem seems to be that when I simply put this in the keymap.sh file (q is my user name)
And it tells me...
So after a reboot my keymappings are all lost.
Any ideas?
Thanks
Jamie
The problem seems to be that when I simply put this in the keymap.sh file (q is my user name)
and then write in terminal "#!/bin/sh
PATH=/home/q/.keymap.conf
#Execute key re-mapping
xmodmap $PATH
"sudo update-rc.d keymap.sh defaults
And it tells me...
So not knowing what I'm doing I add in what I figure to be LSB information at the startupdate-rc.d: warning: /etc/init.d/keymap.sh missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
System start/stop links for /etc/init.d/keymap.sh already exist.
I managed to get rid of the warnings but it stiil tells me "### BEGIN INIT INFO
# Provides: scriptname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
#!/bin/sh
PATH=/home/"user"/.keymap.conf
#Execute key re-mapping
xmodmap $PATH
"System start/stop links for /etc/init.d/keymap.sh already exist.
So after a reboot my keymappings are all lost.
Any ideas?
Thanks
Jamie
-
- Level 1
- Posts: 25
- Joined: Mon Mar 22, 2021 4:01 am
Re: Remap an arbitrary key on keyboard to another output
I have successfully followed the above steps given by Lord_Eager but would like to change one of my keys to the copy command (Ctrl+C) what is the code I must add after the = for this.Lord_Eager wrote: ⤴Sun Jul 29, 2012 12:59 pm This is not what he's searching for.
It's very easy to achieve what you ask for.
First thing you need to know is the key code for the special key you want to configure, to achieve that write in a terminal:xev
a small window will open and since then every key you press, or movement of mouse is recorded and print on terminal, so don't move mouse a press the key you are interested to know the code, and suddenly some values will appear in the terminal window. The one you are interested in is key code. Keep in mind that value or write it down somewhere.
Now write in terminal:
and press Enter.xmodmap -pke > $HOME/.keymap.conf
Then:search for the key code you previously wrote down, and write after the "=" :sudo nano $HOME/.keymap.confCode: Select all
Control_L NoSymbol Control_L NoSymbol Control_L
If your keycode instead is not there in the list it means that the key is not mapped in the layout you choose, so try to add the line you need, something like:
keycode XX = Control_L NoSymbol Control_L NoSymbol Control_L
where "XX" is the key code you previously wrote down.
Save it by pressing Ctrl+o and exit by pressing Ctrl+x.
Now write in the terminal:And check if your special key acts like Ctrl.xmodmap $HOME/.keymap.conf
If it works fine you should in the end write a small script to execute at startup, so that you will have your key mapped every time you start your machine up.
Write in a terminal:
and copy inside the empty file modifying "user" with your account name:sudo nano /etc/init.d/keymap.shsave the file and exit.Code: Select all
#!/bin/sh PATH=/home/"user"/.keymap.conf #Execute key re-mapping xmodmap $PATH
Last thing to do is to write in terminal:Reboot machine and praysudo update-rc.d keymap.sh defaults
it should work, however if it doesn't we could try to understand what's the matter.
I hope it's enough "5yrs old style"
If Ctrl is "Control_L NoSymbol Control_L NoSymbol Control_L"
keycode XX = Control_L NoSymbol Control_L NoSymbol Control_L
what is the copy command (Ctrl+C)?
Any help would be appreciated.