Help Needed to Create a Shortcut for On-Screen Keyboard in KDE

I am looking for assistance in creating a keyboard shortcut to activate and deactivate the On-Screen Keyboard in KDE. I am not sure how to set this up and would appreciate step-by-step guidance.

I tried to create a custom shortcut for it. However, I can’t find any CLI command about On-Screen Keyboard.

Operating System: Fedora Linux 40
KDE Plasma Version: 6.2.0
KDE Frameworks Version: 6.6.0
Qt Version: 6.7.2
Kernel Version: 6.10.12-200.fc40.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i5-8365U CPU @ 1.60GHz
Memory: 15.3 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 620
Manufacturer: Dell Inc.
Product Name: Latitude 5300

I assume the on-screen keyboard in question is maliit-keyboard? I’m on my desktop right now (which is still running Plasma 5 and doesn’t really get along with Wayland), but when I get a chance I’ll do some experimenting on my laptop, which incidentally is also a Dell Latitude running Fedora 40 and Plasma 6.

I am using “On-screen Keyboard” for typing CJK, and it is ibus. When enabling and using virtual keyboard, the vi mode of Kate is horrible, i.e., I can’t see i-beam (cursor) while I am navigating lines. Therefore, I am finding is there any shortcut to disable “On-screen Keyboard”/Virtual Keyboard.

Ah ok, yeah looking at it now, there’s really nothing obvious to go on in the interface. I’ve got a Virtual Keyboard section in System Settings, and all it allows me to do is switch between either Maliit, iBus Wayland, or None.

My train of thought on this is I’d probably want to find out which KDE config file stores that setting, and there might be a safer/more elegant way to handle this, but I’d probably just write a simple shell script and use something like sed to switch the configuration. But I’m not really sure if Plasma auto-loads a modified config?

I’d imagine there’s a more direct route though. On Phosh (I imagine this extends to GNOME in general) for example, toggling the on-screen keyboard is a simple one-liner:

alias kh='gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled false'
alias ks='gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true'

I suspect this might be handled through Kwin. In ~/.config/kwinrc for example, the input method can be set as follows:

[Wayland]
InputMethod=/usr/share/applications/org.github.maliit.keyboard.desktop

But that wouldn’t normally take effect until the next login (although restarting plasmashell may or may not do the trick. Something like the following (although I wouldn’t exactly describe this as “seamless”):

killall plasmashell
kstart kwin --replace
kstart plasmashell

(Note: these might be Plasma 5 specific. My muscle memory hasn’t fully caught up to Plasma 6 lol)