Hacker's Keyboard is a software keyboard for Android, featuring a full 5-row keyboard with arrows, Tab, Esc, Ctrl keys. Also it has a "normal" 4-row keyboard layout, and you can easily switch between them.
Usually, phone users enable 5-row keyboard in landscape mode, and 4-row one in portrait mode; while on a tablet you can set it to always use 5-row keyboard.
Recently I acquired a nice NEC Medias W N-05e phone with a unique 2-screen design. Thanks to this, it's kind of a 2-in-1 device: it can function both as a 4" phone, and as a 5.42" tablet. And in phone-portrait mode, I expect it to show me a 4-row keyboard, while in tablet-portrait mode - a 5-row one. In other words, keyboard size should actually depend not on phone orientation, but on screen width (actually, it's more logical if you think about it for a bit).
Unfortunately, this keyboard didn't offer such feature out-of-the-box, but luckily it's an open source software, so I could easily modify it!
And the compiled *.apk file is here.
Note that as long as there are no other similar devices which can function as both phone and a tablet, I assume that I'm the only one who needs such keyboard, and release it in "works for me" state:
there is no configuration regarding the "landscape" and "portrait" screen width
dictionaries probably don't work
If there are other users of Hacker's keyboard who need this patch - please write me (email at the bottom of this page) - I'll be more then happy to learn what kind of device you have! And maybe will consider to improve it.