I have an android device and every keyboard I connected to it worked with Minecraft PE, mostly.
Here is a list of the default button maps that work on the keyboard (i'm using a kindle fire 5th generation with kindle OS 220.127.116.11 or otherwise known as android 5.1.1)
NOTE: This may not be the same for YOU! YOU may have more support or less support but this is what I have.
KEYBOARD AND MOUSE:
All mouse buttons: nope mouse still has to click and drag.
Q key (drop): Yes this key works.
1-9 (slot selection): Yes these keys work.
E (inventory access): Yes this key works.
F5 (perspective toggle): Yes this key works.
SPACE (jump+fly up): Yes this key works for all functions.
SHIFT (sneak): Yes this key works.
SHIFT (fly down): No this function of the key doesn't work.
W, A, S, D (movement controls): These keys work.
CTRL (sprint): Yes this key works.
T, RETURN (open chat): Yes these keys work.
Z (mob effects): No this key doesn't work.
SLASH (open chat ready for command input): Yes this key works.
remapping keys doesn't work.
LEFT JOYSTICK (movement): This joystick works.
everything else (all of the other functions): They do not work.
upon closer inspection with an app that comes as a freebie with AIDE full version (API demos) and a PS3 controller (it has the same mapping as any XBox controller so you could plug a PS3 controller into a XBox and vice versa)
these are the buttons that the device recieves and detects input from:
(PS family/ XBox family)
R1/Front Right Bumper
R2/Back Right Bumper
L1/Front Left Bumper
L2/Back Left Bumper
Dpad up/Dpad up
Dpad down/Dpad down
Dpad left/Dpad left
Dpad right/Dpad right
Left Stick/Left Stick
Right Stick/Right Stick
R3/Right stick button
L3/Left stick button
Those are the buttons that are detected on the android platform
LT and RT are not detected on XBox one controller, View is back, and the Dpad doesn't show in API Demos app.
EDIT: Xbox one controller has same effect as PS3 and PS4 only left stick controls movement.