HomeTasker7 awesome Bluetooth keyboard shortcuts for Android

7 awesome Bluetooth keyboard shortcuts for Android

Awesome Bluetooth shortcuts for an awesome keyboard

I love Tasker, but I’m sure you understand how annoying text input can be. When it comes to typing longer names, data points or lists of variables to process JSON files in Tasker I often refer 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 the 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 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 in a per-room setting. This time I’m playing with hardware. Xiaomi MiiiW (AliExpress) (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
  • F5: refresh
  • F6: search
  • 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.

Since I have a very cheap but very practical 3D printer Ender 3 (review), I will design labels that can be added to the keyboard, which you can also customise to your liking.

3D printing

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 3D design you will be able to use .SVG files to extrude the icons on top of the files.

Buy Creality Ender 3

Buy it using these links to support NotEnoughTech.

Printing buttons

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, 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.

Tasker

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 the 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

IMPORTANT! Read this if you are not able to find LogCat entries for keyCode events.

In the 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 the accessibility settings 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 Shift, Alt and Ctrl will be available but unless you can see custom Fn functions in your LogCat, you are out of luck for these.

TASKER PROFILE:
Profile: MS Keyboard AI Settings 
Restore: no
State: BT Connected [ Name:MIIIW Dual-mode Keyboard Address:* ]
    Enter: MS Enable AI access+ 
        A1: AutoTools Secure Settings 
            [ Configuration:Set Accessibility Services: true
            Accessibility Services: com.joaomgcd.autoinput/com.joaomgcd.autoinput.service.ServiceAccessibility 
            Timeout (Seconds):60 ]

    Exit: MS Enable AI access- 
A1: AutoTools Secure Settings 
    [ Configuration:Set Accessibility Services: true Timeout (Seconds):60 ]

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 them 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.

F2 Whatsapp

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 (1|0).

On %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.

TASKER PROFILE: F2 Whatsapp
Profile: F2 Whatsapp
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
            Component:BaseMiuiPhoneWindowManager
            Filter:keyCode:132 down:true 
            Grep Filter (Check Help):Off ]
Enter: MS Whatsapp 
    Abort Existing Task
    
    A1: If [ %MSwhatsapp ~ 0 ]
    A2: Launch App [ Package/App Name:WhatsApp 
                    Data: Exclude From Recent Apps:Off 
                    Always Start New Copy:On ] 
    A3: Stop [ With Error:Off Task: ] 
    A4: End If 

    
    A5: If [ %MSwhatsapp ~ 1 ]
    A6: Go Home [ Page:0 ] 
    A7: Stop [ With Error:Off Task: ] 
    A8: End If   

MS Whatsapp

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.

TASKER PROFILE: MS Whatsapp
Profile: MS WhatsApp 
    Restore: no
    Application: WhatsApp
Enter: MS WhatsApp+ 
    A1: Variable Set [ Name:%MSwhatsapp To:1 
        Recurse Variables:Off Do Maths:Off 
        Append:Off Max Rounding Digits:3 ] 

Exit: MS WhatsApp- 
    A1: Variable Set [ Name:%MSwhatsapp To:0 
        Recurse Variables:Off Do Maths:Off 
        Append:Off Max Rounding Digits:3 ]

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.

TASKER PROFILE: F1 Tasker
Profile: F1 Tasker 
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
        Component:BaseMiuiPhoneWindowManager 
        Filter:keyCode:131 down:true 
        Grep Filter (Check Help):Off ]
Enter: MS Tasker 
    Abort Existing Task
    A1: Launch App [ Package/App Name:Tasker 
        Data: Exclude From Recent Apps:Off 
        Always Start New Copy:On ] 

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!

TASKER PROFILE: MS Go Home
Profile: MS Go Home 
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
        Component:BaseMiuiPhoneWindowManager 
        Filter:keyCode:117 down:true 
        Grep Filter (Check Help):Off ]
Enter: MS Go Home 
    A1: Go Home [ Page:0 ] 

On Windows, 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:

  • AltkeyCode 57
  • CtrlkeyCode 113
  • DelkeyCode 112

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 keyCode:131 down:false.

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 %MSlockscreenCtrl & %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.

TASKER PROFILE:MS Lock Screen Ctrl Down
Profile: MS Lock Screen Ctrl Down 
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
        Component:BaseMiuiPhoneWindowManager 
        Filter:keyCode:113 down:true 
        Grep Filter (Check Help):Off ]
Enter: MS LockScreen Ctrl+ 
    A1: Variable Set [ Name:%MSlockscreenCtrl To:1 
        Recurse Variables:Off Do Maths:Off 
        Append:Off Max Rounding Digits:3 ]
TASKER PROFILE:MS Lock Screen Ctrl Up
Profile: MS Lock Screen Ctrl Up 
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
        Component:BaseMiuiPhoneWindowManager 
        Filter:keyCode:113 down:false
        Grep Filter (Check Help):Off ]
Enter: MS LockScreen Ctrl+ 
    A1: Variable Set [ Name:%MSlockscreenCtrl To:0 
        Recurse Variables:Off Do Maths:Off 
        Append:Off Max Rounding Digits:3 ]
TASKER PROFILE: MS Lock Screen Alt Down
Profile: MS Lock Screen Alt Down 
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
        Component:BaseMiuiPhoneWindowManager 
        Filter:keyCode:57 down:true 
        Grep Filter (Check Help):Off ]
Enter: MS LockScreen Alt+ 
    A1: Variable Set [ Name:%MSlockscreenAlt To:1 
        Recurse Variables:Off Do Maths:Off 
        Append:Off Max Rounding Digits:3 ]
TASKER PROFILE: MS Lock Screen Alt Up
Profile: MS Lock Screen Alt Up
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
        Component:BaseMiuiPhoneWindowManager 
        Filter:keyCode:57 down:false 
        Grep Filter (Check Help):Off ]
Enter: MS LockScreen Alt+ 
    A1: Variable Set [ Name:%MSlockscreenAlt To:0 
        Recurse Variables:Off Do Maths:Off 
        Append:Off Max Rounding Digits:3 ]

Delete

This shortcut gets a normal assignment keyCode:112 down:true, but will only use System Lock action IF %MSlockscreenCtrl AND %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.

TASKER PROFILE:
Profile: MS Lock Screen Delete 
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
        Component:BaseMiuiPhoneWindowManager 
        Filter:keyCode:112 down:true 
        Grep Filter (Check Help):Off ]
Enter: MS LockScreen Delete 
    A1: System Lock If [ %MSlockscreenAlt ~ 1 & %MSlockscreenCtrl ~ 1 ]

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 Enter 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.

TASKER PROFILE: MS WhatsApp Send
Profile: MS WhatsApp Send 
    Restore: no
    Application: WhatsApp or Messages
    Event: Logcat Entry [ Output Variables:* 
        Component:BaseMiuiPhoneWindowManager 
        Filter:keyCode:66 down:true 
        Grep Filter (Check Help):Off ]
Enter: MS Send Via Enter 
    
    A1: AutoInput Action [ Configuration:Type: Text
        Value: Send
        Action : Click Timeout (Seconds):23 ] 
        If [ %MSwhatsapp eq 1 ]

    
    A2: AutoInput Action [ Configuration:Type: Text
        Value: Send SMS
        Action : Click Timeout (Seconds):23 ] 
        If [ %MSmessages eq 1 ]

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.

TASKER PROFILE: MS Play Music
Profile: MS Play Music 
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
        Component:BaseMiuiPhoneWindowManager 
        Filter:keyCode:85 down:true 
        Grep Filter (Check Help):Off ]
Enter: MS Launch Music 
    A1: Launch App [ Package/App Name:Play Music Data: 
        Exclude From Recent Apps:Off 
        Always Start New Copy:Off ] 
        If [ %MSmusic eq 0 ]

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.

TASKER PROFILE: MS Play Music Notification
Profile: MS Play Music Notification 
    Restore: no
    State: AutoNotification Intercept 
        [ Configuration:Has Media Session: true
        Notification App: Google Play Music ]
Enter: MS Launch Music Monitor+ 
    A1: Variable Set [ Name:%MSmusic To:1 
    Recurse Variables:Off Do Maths:Off 
    Append:Off Max Rounding Digits:3 ] 

Exit: MS Launch Music Monitor- 
    A1: Variable Set [ Name:%MSmusic To:0 
    Recurse Variables:Off Do Maths:Off 
    Append:Off Max Rounding Digits:3 ] 

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 %MSstatusbarCtrl and 1|0 values. You can use left Ctrl if you want, then you can lean on already created %MSlockscreenCtrl.

TASKER PROFILE: MS Status Bar Ctrl R Down
Profile: MS Status Bar Ctrl R Down 
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
    Component:BaseMiuiPhoneWindowManager 
    Filter:keyCode:114 down:true 
    Grep Filter (Check Help):Off ]
Enter: MS StatusBar Ctrl+ 
    A1: Variable Set [ Name:%MSstatusbarCtrl To:1 
        Recurse Variables:Off Do Maths:Off 
        Append:Off Max Rounding Digits:3 ]
TASKER PROFILE: MS Status Bar Ctrl R Up
Profile: MS Status Bar Ctrl R Down 
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
    Component:BaseMiuiPhoneWindowManager 
    Filter:keyCode:114 down:false 
    Grep Filter (Check Help):Off ]
Enter: MS StatusBar Ctrl+ 
    A1: Variable Set [ Name:%MSstatusbarCtrl To:0 
        Recurse Variables:Off Do Maths:Off 
        Append:Off Max Rounding Digits:3 ]

Use Tasker’s action Status Bar to expand and collapse the bar on PageUp (keyCode: 92 down:true) and PageDown (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 %MSstatusbar to 1 if the status bar is expanded and 0 if the action is collapsing it.

TASKER PROFILE: MS Status Bar Expand
Profile: MS Status Bar Expand 
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
        Component:BaseMiuiPhoneWindowManager 
        Filter:keyCode:93 down:true 
        Grep Filter (Check Help):Off ]
Enter: MS Pulldown 
    A1: If [ %MSstatusbarCtrl eq 1 ]
    A2: Status Bar [ Set:Expanded ] 
    A3: Variable Set [ Name:%MSstatusbar To:1 
        Recurse Variables:Off Do Maths:Off 
        Append:Off Max Rounding Digits:3 ]
TASKER PROFILE: MS Status Bar Collapse
Profile: MS Status Bar Collapse 
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
        Component:BaseMiuiPhoneWindowManager 
        Filter:keyCode:92 down:true 
        Grep Filter (Check Help):Off ]
Enter: MS Collapse 
    A1: If [ %MSstatusbarCtrl eq 1 ]
    A2: Status Bar [ Set:Collapsed ] 
    A3: Variable Set [ Name:%MSstatusbar To:0 
        Recurse Variables:Off Do Maths:Off 
        Append:Off Max Rounding Digits:3 ] 

Delete Notifications

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.

TASKER PROFILE: MS Status Bar Delete
Profile: MS Status Bar Delete 
    Restore: no
    Event: Logcat Entry [ Output Variables:* 
        Component:BaseMiuiPhoneWindowManager 
        Filter:keyCode:112 down:true 
        Grep Filter (Check Help):Off ]
Enter: MS Clear Notifications 
    A1: If [ %MSstatusbarCtrl eq 1 ]
    A2: AutoNotification Cancel [ Configuration:Cancel All: true 
        Timeout (Seconds):20 ] 
        If [ %MSstatusbar eq 1 ]

Conclusion

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 (AliExpress). 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.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How to wake on LAN computers and put it to sleep with Power Menu,...

0
How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

Smart overnight charging with Tasker

0
Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

0
It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

Tasker weather notification tutorial

0
Fancy some training on .json, subroutines, arrays and loops?

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

0
It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

0
Keep your Tasker tidy!

A better way to store Tasker credentials

0
The more clever way of managing credentials

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

0
Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

0
Who wants a piece of the pie (chart)?