Toggle onscreen keyboard

It would be nice to be able to toggle the onscreen keyboard visibility as an action in BTT.

If you have multiple inputs enabled, there is an option in the menu bar to toggle it, but I was unable to find a keyboard shortcut that maps to it.

Possibly see How to toggle on macos virtual keyboard via trackpad ?

I have only tested the Apple Script posted there on macOS Catalina though.

Thank you for the response. The linked content did not work for me, but I searched some more and stumbled on this: https://apple.stackexchange.com/a/62532

My final script is the following:

tell application "System Events"
	set frontmostApplicationName to name of 1st process whose frontmost is true
end tell

tell application "System Events"
	key code 49 using {control down}
end tell

if application "KeyboardViewer" is running then
	quit application "KeyboardViewer"
else
	activate application "KeyboardViewer"
end if

tell application frontmostApplicationName
	activate
end tell

It switches the input (requires keyboard shortcut Ctrl + Space to be mapped to next input), toggles the virtual keyboard, and restores focus onto the current application (the virtual keyboard steals it).

1 Like