ROOT USERS ONLY!!! For non-rooted devices, use Keyboard Manager Plus: https://play.google.com/store/apps/details?id=com.ne0fhykLabs.android.utility.kmplus Keyboard Manager allows you to customize what keyboard appears based on your device configuration.
It displays the keyboards you have enabled on your android device, and let you select one per orientation (landscape/portrait).
As your phone switch orientation, the app automatically switch the keyboard.
The app is open source (MPL v2), and the source code is available @ https://bitbucket.org/ne0fhyk/keyboard-manager/src