I love Tasker, but I’m sure you understand how annoying text input can be. When it comes to typing longer names, data point or list of variables to process JSON files in Tasker I often refrain to AirDroid screencasting and Join to copy and paste clipboard across. All in an attempt to speed up the boring bits. Thanks to Xiaomi MiiiW (review), I can switch between my PC and Android phone in an instance, so all I’m missing are some useful shortcuts. While I show this on Xiaomi keyboard, this hack will work with all Bluetooth keyboards.
Filling in the blanks
I know certain apps come with PC interfaces (WhatsApp Web, etc), but especially at work when computer activity is a subject to security and scrutiny of your superiors, this might be strongly frowned upon. These shortcuts open up a serious window for productive slacking, reducing the time you will spend glaring on your phone or responding to messages.
I played with interactive shortcuts before. In my Smart NavBar Tutorial, I was able to control music, clipboard, alarms, or even smart lights on per-room setting. This time I’m playing with hardware. Xiaomi MiiiW (how do you pronounce this?) comes with built-in shortcuts. These are activated with
Fn button and you can:
F1-2: control brightness
F3: recent apps
F4: not active
F7-9: playback controls
F10-12: volume control
Windows Key: Google Assistant
These will activate with
Fn+ combination or when the keyboard functions are locked (
Fn+Esc). To my knowledge, the default keys
F1-12 are completely useless, and we can use it to map pretty much anything we want. So this is my plan, to improve the current shortcuts rooster and introduce new, useful actions.
This step is optional, but it will definitely add some flair to your keyboard and if you show up at a LAN party… Ok, it’s not 1995… Using Fusion360 I designed a lip that goes over the top buttons without obstructing the keys or the position of the mobile phone.
The lip comes with 7mm x 7mm slots, that can be populated with 6.5mm x 6.5mm buttons. A total of 12 buttons is needed to customise the keyboard. I made this modular, as I want you to be in charge of the button order and functions.
If you have basic skills in a 3D design you will be able to use .SVG files to extrude the icons on top of the files.
The buttons are tiny, so the label cannot be too complicated. If the resolution of the label is thinner than the extruder capabilities, it will be omitted. There are 2 routes to take:
- Print as one, paint later
- Print the base, pause, change filament, print out the icon with a different colour
If you want to paint the buttons, the white filament is recommended. Prime the button first, then use acrylic paint to paint the icons to your liking. Use wash and drybrush techniques to bring out the details. Allow the paint to dry and use acrylic varnish to seal the button and prevent the paint from rubbing off.
You can skip painting entirely if you have two contrasting in colour filaments. Print out the base of the button, and use Cura – Extensions – Post Processing – Modify G Code to add script at line 14 (if you use my .STL). You can pause the print and move the extruder to
x:0 y:0, retract the filament and change it to a different colour. The printer will wait until you are done.
Thanks to Tasker and the latest LogCat event I can intercept button presses on Xiaomi Mi9 (review). The
F1-12 are identified as 131-142 and can be intercepted with:
#Component BaseMiuiPhoneWindowManager #Filter keyCode:131 down:true
Due to Component name being ROM specific, you will have to look up your actual name using LogCat. If you never used the LogCat Event before here is the visual guide:
AutoInput as an alternative
In case of my Pixel 3 running on both Android 9 and Android 10, I was not able to detect these entries. You can still enable the same functionality with
Event - AutoInput Key. In addition to that, you could create a Bluetooth profile to enable and disable accessibility setting for AutoInput when the keyboard is connected|disconnected. You can achieve this with
AutoTools Security Setting (Accessibility Services).
AutoInput uses the same system to intercept key presses. Shortcuts with
Ctrl will be available but unless you can see custom
Fn functions in your LogCat, you are out of luck for these.
On to the shortcuts
Obviously, use it with key input and search for
keyCode. I suspect the keyCode for
F1-12 will be the same for everyone, regardless of the keyboard used. If you want to map other keys, you will have to intercept it one by one.
We know how to trigger Tasker on keystrokes, so let’s create some fun shortcuts. Leave me a comment in this Reddit thread if you come up with other fun shortcuts.
This shortcut will launch any app (other than Tasker) and will exit the app when pressed again. You will be able to switch from app to app as well without exiting previous apps. For each app, you will need to add a separate profile.
If the app isn’t open (see Whatsapp Profile below) I’m going to use a Launch App action. Wrap this in IF/End IF statement and link it to
%MSwhatsapp variable (
%MSwhatsapp = 0, the action opens the app and stops with a STOP action. On
%MSwhatsapp = 1, the action Go Home returns you to the home screen.
This profile monitors Whatsapp and sets the %MSwhatsapp to (
1|0) depending on the app and its current state. Thanks to this information, the main profile knows if it should open the app or return to the Home Screen.
Do this for each app, changing the app in the trigger, the names of the
%MS.... variable and the IF conditions. If you are curious why my variables are named like
%MSwhatsapp, take a look at this article which will tell you how to organise your Tasker projects better.
If you wonder why Tasker launcher is listed as a separate profile, it’s because Tasker cannot monitor itself. Unfortunately, you won’t be able to toggle it out. You can launch Tasker with a hardware button, but to exit it out, you need to use your mobile phone.
MS Tasker profile
Simply, link your LogCat event trigger with the Launch App action. That’s all. Tasker will open, but you won’t be able to exit it out with another press of the same button.
You should be able to use the Go Home shortcut or switch to another app.
Go to Desktop Fn Shortcut isn’t working on Android, so I thought I would fix this. I’d rather map this to an existing label than take one of the
F1-12 keys. The
Fn+F4 combination gives you
keyCode117. With the trigger sorted, the action is rather simple – use GoHome action and link it all together!
Alt+Ctrl+Del combination is known to many of you. I’m going to use this combination to lock the screen for 2 reasons:
- can’t be pressed by accident
- you will learn how to use complicated shortcuts
First, we have to find the keyCodes for each key:
- Alt –
- Ctrl –
- Del –
Bear in mind that Alt and Crtl keyCode could be different on your keyboard if there is a distinction between left and right key. Run LogCat to check it. Apart from the keyCode, LogCat intercepts the button event type. Until now I was interested in
keyCode:131 down:true but to act on
Alt+Ctrl+Del I will also need
You probably know what I’m going to do. I’m going to create a separate profile for each key:
Ctrl & Alt
Both keys need to be held down. Since I deal with events not states, the best way to do it is to assign a variable to each button
%MSlockscreenAlt will set 1 when the code is:
keyCode:113/57 down:true and will reset back to 0 when the code is
keyCode: 113/57 down:false.
This shortcut gets a normal assignment
keyCode:112 down:true, but will only use System Lock action IF
%MSlockscreenAlt are both set to 1.
Bear in mind, that if you added your keyboard as a trusted device, anyone will be able to unlock your screen, by pressing any key on your keyboard.
In case you don’t want to use Enter to send every message, and you don’t want to change this setting each time you open WhatsApp or other apps, there is a way to automate it with AutoInput.
You can use AutoInput Action to touch the send command on
keyCode: 66 down:true (or
Shift+Enter). Proceed with the key intercept as you would in other sections. I suspect for every app you will need a separate AutoInput Action. You can limit the number the profiles you have by reusing app variables from Launch an app section.
This way individual AutoInput Action will be executed when a certain app is open (ie
%MSwhatsapp = 1). If you enable AutoInput permissions (do everything as with AutoTools but use
com.joaomgcd.autoinput)- you will be able to enable and disable Accessibility settings just before and after the action speeding up your system.
While you can control the playback from the Xiaomi MiiiW, you cannot start one by hitting the Play/Pause button. Let’s fix this. Since we are going to use the same button to open the app and control the playback, we have to control the actions in some way.
Play Music Notification
I’m using AutoNotification to intercept the media notification based on the app type and media session requirement. This will set the variable %MSmusic to 1|0 accordingly.
Now, that I know when the media is already launched, I can use the
keyCode:89 down:true to launch the app as I would in my first profile with the Launch App Action.
If you want to start the playback right away, you can use a Media Control action (Play – Simulated only). If you want to launch a specific playlist or automate it further – check the intents available for your music player.
To speed up your amazing mobile slacking, I have added the option to expand and collapse the notification bar (status bar). On top of this, you will get the option to dismiss all notifications (but only when that status bar had been open via keyboard shortcuts.
I’m going to use the following shortcuts:
Ctrl + PageDown: expand the status bar
Ctrl + PageUp: collapse the status bar
Ctrl + Delete: delete all notifications
In a similar fashion to
Alt+Ctlr+Del I’m going to use a separate profile to monitor when the right
Ctrl is down (
keyCode: 112). It will control the variable
1|0 values. You can use left
Ctrl if you want, then you can lean on already created
Use Tasker’s action Status Bar to expand and collapse the bar on
keyCode: 92 down:true) and
keyCode: 93 down:true) events. Make sure the code is wrapped in IF condition and activates only when %
MSlockscreenCtrl = 1. Each task should also set the variable
1 if the status bar is expanded and
0 if the action is collapsing it.
I don’t want my notifications to be accidentally dismissed, so I will only execute AutoNotification Cancel All when the status bar had been opened via key shortcut. This is why this action is linked with IF
%MSstatusbar = 1 and wrapped in IF condition that checks if the
Ctrl key is down –
%MSlockscreenCtrl = 1.
Buy Xiaomi MiiiW Keyboard
Buy it using these links to support NotEnoughTech.
If you have a spare Bluetooth keyboard laying around, you can use it with your phone to become a power user. If you are thinking about a keyboard that can be used for both PC/Mac and mobile phones, consider Xiaomi MiiiW Keyboard. It’s pretty great, just don’t tell your boss you got one! Let me know if you have fun projects in mind in this Reddit thread.
Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.