I used Root App Deleter to disable the stock keyboard app. That way I just keep using SwiftKey whether using physical keyboard or not.
Note: SwiftKey only lets me use the English layout when using a physical keyboard. I normally type in both English and Norwegian, and like to switch between layouts. The Samsung stock keyboard let me easily do this by pressing alt+Shift. As far as I can see, Swiftkey has me locked onto English layout when using a physical keyboard. If you want to be able to switch between different layouts, you will be better off using the Tasker method suggested by Izzy.
With SwiftKey, the soft keyboard disappears from the screen as soon as the physical keyboard is connected. One catch is that there is annoying message I have to click OK to every time I connect the physical keyboard, but that is okay. It just amounts to a simple press of the Enter key.
Warnings:
- This method worked on my particular device and ROM, but there is no guarantee that it will work on other devices and/or ROMs. The app I linked to above requires root. Do NOT delete the stock keyboard app of your device, just disable it. Even disabling the stock keyboard app of your device may in some rare devices and ROMs cause the system to misbehave. If that happens to you you can use the same app to reenable the stock keyboard app again, and use the Tasker method suggested by Izzy in the comments instead.
- A very small number of Android ROMs may be unable to reenable apps after having disabled them with this app. The app has a test module that you should run before disabling any apps, to make sure that reenabling them again will work.
- With the OS default keyboard unavailable, there might be issues with lock screen (enter password/pin) as well as encryption (same thing), which might rely on the "stock keyboard". Such cases already have been reported here – see e.g. How to enter password for decrypt without system keyboard on android. Especially for the encryption password, this is a logical consequence: the user-installed keyboard app is stored on the user partition (
/data
), which is encrypted – so the keyboard cannot be loaded before that partition is decrypted, which requires the user to enter the passphrase; a typical dead-lock situation..
- In general, use this (and all other) root apps at your own risk, and backup your system with clockworkmod/twrp regularly if you have a rooted device and use root-applications.