On many older laptops and some compact keyboards there is an integrated numeric keypad in the main keyboard area. This alternate keypad is activated with a special 'Fn' key next to the left Ctrl key.
As a programmer I learned to use the cursor movement keys (arrows, PgUp, PgDn etc.) and found it greatly improved my programming speed. And the benefits were not bound to just a single application as is the case with specialised shortcut keys.
On conventional PC keyboards, the 'Windows Key' can be used to emulate the 'Fn' key and a corresponding integrated numeric keypad. When I used to use MS Windows I found Autohotkey was able to map the keys using a simple script.
Recently I learned about xkb and how it can be used to map keystrokes at a very low level.
What is the xkb keyboard mapping profile that will emulate an integrated numeric keypad using the windows key as the fn key?
Hint(?): I suspect the file will look a lot like the '/usr/share/X11/xkb/symbols/keypad' file on a Debian-derivative linux distro. This 'keypad' file is included at the top of the '/usr/share/X11/xkb/symbols/pc' file.
The corresponding autohotkey script for reference (# == WinKey):
#8::Up
#k::Down
#u::Left
#o::Right
#7::Home
#j::End
#9::PgUp
#l::PgDn
#m::Insert
#.::Delete
;(Scroll with the left-over keys)
#i::WheelUp
#,::WheelDown
Note that all these keys need to work with any combination of Ctrl, Alt, Shift as well as the Windows Key.
Steps to install numeric keypad-like cursor keys on the main keyboard in Linux / XKB...
xkbcomp $DISPLAY original.xkb (just in case ;)
xkbcomp $DISPLAY custom.xkb
Edit custom.xkb
Add the following at the end of section: xkb_types "..." {
type "WinKeyAsFnKey" {
modifiers = Shift+Super;
map[Shift] = level2;
map[Super] = level3;
map[Super+Shift] = level3;
level_name[Level1] = "Base";
level_name[Level2] = "Caps";
level_name[Level3] = "Fn";
};
Add the following at the end of section xkb_symbols "..." {
key <AE07> {type="WinKeyAsFnKey",symbols[Group1]=[7,ampersand,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<HOME>,clearmods=Super)]};
key <AE08> {type="WinKeyAsFnKey",symbols[Group1]=[8,asterisk,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<UP>,clearmods=Super)]};
key <AE09> {type="WinKeyAsFnKey",symbols[Group1]=[9,parenleft,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<PGUP>,clearmods=Super)]};
key <AD07> {type="WinKeyAsFnKey",symbols[Group1]=[u,U,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<LEFT>,clearmods=Super)]};
key <AD09> {type="WinKeyAsFnKey",symbols[Group1]=[o,O,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<RGHT>,clearmods=Super)]};
key <AC07> {type="WinKeyAsFnKey",symbols[Group1]=[j,J,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<END>,clearmods=Super)]};
key <AC08> {type="WinKeyAsFnKey",symbols[Group1]=[k,K,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<DOWN>,clearmods=Super)]};
key <AC09> {type="WinKeyAsFnKey",symbols[Group1]=[l,L,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<PGDN>,clearmods=Super)]};
key <AB07> {type="WinKeyAsFnKey",symbols[Group1]=[m,M,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<INS>,clearmods=Super)]};
key <AB09> {type="WinKeyAsFnKey",symbols[Group1]=[period,greater,NoSymbol],actions=[NoAction(),NoAction(),RedirectKey(key=<DELE>,clearmods=Super)]};
Save custom.xkb
xkbcomp custom.xkb $DISPLAY
I'm still working on the mouse scroll with 'i' and ','.
EDIT:
The above solution does not play nice with Google Chrome and Chrome-based apps (like Slack).
Alternative approach is to use a programmable keyboard. I use an after-market PCB for a CoolerMaster Masterkeys S keyboard. The Easy AVR layout is available online (although currently the left win-key now doesn't work by itself...I use the right one).
The new keyboard doesn't have keys for media control (the image on Amazon was small). I want to re-purpose the keys for e-mail, sleep, calculator, etc... into media control keys.
This is my keyboard:
Keyboard-Amazon
I've researched AutoHotKey and found that this is possible; however, I am not sure how to fully implement it. I cannot find any way to identify these keys to the program. I would be happy if you could tell me how to identify these keys to the program and how to get it to respond in the correct way. That is, next track and previous track selection.
Autohotkey has built in support for some multimedia keys.
Browser_Back
Browser_Forward
Browser_Refresh
Browser_Stop
Browser_Search
Browser_Favorites
Browser_Home
Volume_Mute
Volume_Down
Volume_Up
Media_Next
Media_Prev
Media_Stop
Media_Play_Pause
Launch_Mail
Launch_Media
Launch_App1
Launch_App2
Use them with a send command, example:
F11::Send,{Media_Play_Pause}
If you keyboard had special keys you will have to consult the documentation on that.
Let's say I pressed "=" on my English keyboard. If I switch my keyboard language to Turkish, pressing the same key gives me a "-". So I am easly able to say that my operation system interprets the key presses.
My question is, is it possible to get the a key's real value so that no matter which language is used, I can know which key is pressed? Later, I need to use this value(s) with RegisterHotKey.
You use virtual key codes, vs keyboard scan codes which are language dependant.
You didn't specify a programming language, but these should be independant of language and OS. Virtual-Key Codes link
I'm looking to reassign the function of my keyboard's "NumLock" key. Essentially I'd like to use the "NumLock" key to select multiple items on a spreadsheet, instead of using the "Ctrl" key to select multiple items. Anyone have a quick fix or can direct me to a third party solution?
thanks in advance,
You can use AutoHotkey to achieve this. One of the neat things about AHK is that it provides remap functionality, so your numlock key can become a second ctrl.
I'm trying to intercept the Ctrl/Chr key on a full QWERTY Nokia device (E71). It seems like the keyPress event isn't generated for this particular key.
Any ideas?
There is a good chance that this key is only a keycode modifier.
You can probably only see whether it is pressed at the same time as another one.
It would not exactly but the first key to not trigger a Canvas.keyPressed() callback on a phone.