How to map hard key combinations to keys in Motorola Photon Q XT897?
There are two "layers" in the hardware keypress -> character to insert in textbox. The layer after key layout files is Key Character Map Files. They take the key (such as "A") and dictate what should result from various combinations of keys. For example:

key A {
  label: "A" # What to 'name' the key
  base: "a" # pressing this key with no modifiers
  shift, capslock: "A" # if either shift or capslock is on, do a capital a instead
  ctrl, alt, meta: none # do nothing if any other combinations are pressed
}


Backup, then edit the .kcm file corresponding to the hardware keyboard. You will need root. 

If your file has any syntax errors then it will simply revert to the default keyboard mapping which is mostly but not fully correct. The only way to check for syntax errors besides putting the file in and rebooting the device is to compile the entirety of the android source code.