is there a list of possible “junk keys” that one can abuse for custom shortcuts in KDE? I am using kbct to mod some keys and basically just would like to have some keys that do nothing in the system but can still be handled in KDE.
like how Copilot is using F23 (along with some modifiers), I have tried remapping something to F24 to hopefully start a script to do stuff but sadly the key binder doesnt see F24.
so the question is obviously what CAN I use?
Currently on KDE 5.27.12-0ubuntu0.1 (Kubuntu 24.04)
can input remapper also mess with modifiers? e.g. R-Alt + leftarrow → L-Alt + leftarrow (R-Alt behaves differently on a german keyboard) or L-Shift + L-Meta + F23 (copilot key) → context menu key, or R-Alt + L-Shift + L-Meta + F23 (R-Alt + Copilot key) → right Alt + < (which creates a pipe on german keyboard)
or run scripts (as otherwise we are at the same issue of needing a place to dump the input first to catch it) such as context menu (physical behind Fn, not cause issues with the above mapping to create the context menu key in a nicer place) ->script to turn on/off touchscreen
it can recognize all the physical keys and remap them to pretty much anything you want.
you could map
Control L + F1 ⇒ KEY_F13
or
Alt L + F12 ⇒ KEY_F24
now what KEY_F13 or KEY_F24 does is another matter entirely, but it will send that key code to the OS
-–
you can also write macros… the macro language syntax is a bit tedious but workable.
it can write out entire strings of text at a given shortcut combo… i wrote this short script to handle most of the alpha numeric things you might want to write, but it gives you an idea how the macro language works.
macro_generator
#!/bin/bash
#uncomment the next line for diagnostic help.
# set -x
#this will take written input and write an input-remapper macro to produce
#the exact same string which can be mapped to a keyboard shortcut
textIn=$(kdialog --textinputbox "write the desired macro output" "Hello, World!")
len=${#textIn}
macro=""
for (( i=0; i<$len; i++)) ; do
ch=${textIn:$i:1}
#covers upper&lower case and a few punctuation characters, or exits if not listed
case $ch in
[a-z] | [0-9])
macro="$macro key($ch)."
;;
[A-Z])
macro="$macro modify(shift_L,key($ch))."
;;
\`)
macro="$macro key(KEY_GRAVE)."
;;
\~)
macro="$macro modify(shift_L,key(KEY_GRAVE))."
;;
!)
macro="$macro modify(shift_L,key(1))."
;;
@)
macro="$macro modify(shift_L,key(2))."
;;
\#)
macro="$macro modify(shift_L,key(3))."
;;
$)
macro="$macro modify(shift_L,key(4))."
;;
%)
macro="$macro modify(shift_L,key(5))."
;;
^)
macro="$macro modify(shift_L,key(6))."
;;
\&)
macro="$macro modify(shift_L,key(7))."
;;
\*)
macro="$macro modify(shift_L,key(8))."
;;
\()
macro="$macro modify(shift_L,key(9))."
;;
\))
macro="$macro modify(shift_L,key(0))."
;;
-)
macro="$macro key(KEY_MINUS)."
;;
_)
macro="$macro modify(shift_L,key(KEY_MINUS))."
;;
=)
macro="$macro key(KEY_EQUAL)."
;;
+)
macro="$macro modify(shift_L,key(KEY_EQUAL))."
;;
[)
macro="$macro key(KEY_LEFTBRACE)."
;;
{)
macro="$macro modify(shift_L,key(KEY_LEFTBRACE))."
;;
])
macro="$macro key(KEY_RIGHTBRACE)."
;;
})
macro="$macro modify(shift_L,key(KEY_RIGHTBRACE))."
;;
\\)
macro="$macro key(KEY_BACKSLASH)."
;;
\|)
macro="$macro modify(shift_L,key(KEY_BACKSLASH))."
;;
\;)
macro="$macro key(KEY_SEMICOLON)."
;;
:)
macro="$macro modify(shift_L,key(KEY_SEMICOLON))."
;;
\')
macro="$macro key(KEY_APOSTROPHE)."
;;
\")
macro="$macro modify(shift_L,key(KEY_APOSTROPHE))."
;;
,)
macro="$macro key(KEY_COMMA)."
;;
\<)
macro="$macro modify(shift_L,key(KEY_COMMA))."
;;
.)
macro="$macro key(KEY_DOT)."
;;
\>)
macro="$macro modify(shift_L,key(KEY_DOT))."
;;
/)
macro="$macro key(KEY_SLASH)."
;;
\?)
macro="$macro modify(shift_L,key(KEY_SLASH))."
;;
' ')
macro="$macro key(space)."
;;
*)
echo "$ch is not allowed"
exit 1
;;
esac
((n++))
if [[ $n -gt 3 ]] ; then
macro=$macro"\n" #keeps output to reasonable line lengths
n=0
fi
done
macro="$macro key(KEY_ENTER)"
kdialog --textinputbox "copy the result and paste it\ninto input-remapper's output box" "$macro"
and that is kinda where I am stuck, as I thought to use KDE global/custom shortcuts to e.g. run scripts that e.g. use xinput to turn on/off the touch screen with a nice OSD Message
but to use the copilot key would take a bit more work.
see if input-remapper will recognize the copilot key when you “record” a new keybind… if so then you can have that mapped to whatever shortcut you assigned to the command above which will act as an intermediary.
problem is that considering I am not just the copilot key but I also wanna combine it with Right Alt, which acts differently on a german keyboard (AltGr) and therefore is ignored for keybinds I need to get creative, so I thought okay lets make it via a remapper that doesnt care what the UI thinks, and map stuff to F13 and up, but yeah that goes as well as it does (not at all) and copilot alone similarly wouldnt work due to it being LShift+LWin+F23, which is in the same situation of being ignored.
also I am obviously trying to use obscure keys to avoid posible collisions, who knows what applications might have.
for AltGr, I kinda need that as some fairly important stuff is in there, like @ \ ~ or {[]}, so taking it and redefining it really should be reserved to special key combos.
The copilot key is a sad story. Microsoft mandates that it’s implemented in a way that makes it halfway useless to re-map, because it’s required to send key press and release events when simply pressed (not released). So you can’t re-bind it to be a modifier key.
Not even trying to use copilot as a modifier but rather use copilot with a modifier that isn’t considered a modifier in Linux (altgr).
Also i don’t even remember the copilot key having an early release mechanism to ebgin with in the kbct logs. I’ll have to try after work as i don’t have another thing with the copilot key.
That’s actually worse than I realised. Implementing it as a combination rather than a modifier is bad enough (if Copilot = Meta+Shift+F23, then you can’t distinguish Copilot from Shift+Copilot, at least not without doing some heuristics on the event stream).
Just making it F23, and having Windows interpret F23 as “invoke Copilot”, would have been much better.
A bit of blame for manufacturers too? They could have implemented a BIOS setting to allow non-Windows users to choose saner behaviour.
considering copilot specifically triggers L-Shift + L-Meta + F23 you can theoretically distinguish if you use R-Shift instead if your keyboard handler is good enough.
especially when the manufacturer LITERALLY offers their laptops also with linux or no os.
and they already have some fairly deep bios settings like switch ctrl/fn, which is definitely not trivial considering how fn is usually handled.
but I really need to check my thinkpad when I get home because as far as I remember kbct logs seemed like it normally triggered L-Shift+L-Meta+F23 when pushing it, and keeping it held until I release.
but copilot key notwithstanding, if there are just some “blank” keycodes I could abuse in kbct to trigger shortcuts i’d already be extremely happy, and heck even the more crazy AltGr+Copilot → AltGr + < (known in Javascript as intlbackslash or in kbct just as 102nd, lol) which doesnt work in kbct at the moment as kbct throws out the originally pressed modifiers so I cant carry AltGr through could be done if I can force it to type something using a script or whatever.
but considering how low level kbct interacts the possibilities are near endless. (literally “steals” the input devices you tell it to and opens up a new one for the system to use, as far as the readme goes).
What about combos with several modifiers? e.g. Ctrl+Shift+Alt+(key) or Ctrl+Shift+Alt+Meta+(key) ? (QMK calls these “Meh” and “Hyper” respectively and people often use them in custom QMK layouts exactly because they’re unlikely to interfere with already existing shortcuts.)
cool idea I’ll need to check how well that works especially when I am using modifiers on the sending side already, as kbct seems to be unable to keep the modifiers alive that I am already using at this point, so this will be a bit of trial and error what I can actually do.
I didnt exactly thought of that as I was I guess hyper focused on the idea of unused keys (well apprently they arent always unused as KDE uses F22/F23 as touchpad on/off respectively (which I guess is something fun I can abuse anyway as that certainly has its use too.
AltGr is only used to access additional characters (if you have any) in your keyboard layout like the shift key for an additional two characters per key cap… it cannot be used as a modifier.
however you can change which key is the AltGr in the keyboard settings (Advanced tab) by selecting a different key for the 3rd level shift function… in which case your “AltGr” key should return to just being the Alt_R key.
getting back to what input-remapper says when you try to record the key press, are you saying that
i recorded the combo meta+alt_r on my keyboard to generate what is shown, but my alt_r key is assigned to AltGr instead so i can access the other characters in my keyboard layout.
that said, i retract what i wrote about not being able to use AltGr as a modifier, since i clearly just did and when i assign that combo to KEY_F13 it will do that F13 does on my system (which is apparently to close the focused window).