There are a few links that you can follow up about this that are on site
Set custom keyboard for android application
creating custom android keyboard layout
How to develop a soft keyboard for Android?
And a couple off site open source programs
http://code.google.com/p/hackerskeyboard/
http://code.google.com/p/softkeyboard/
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.1_r1/com/example/android/softkeyboard/SoftKeyboard.java
http://www.java2s.com/Code/Android/User-Event/Exampleofwritinganinputmethodforasoftkeyboard.htm
An overview of the standard android input method
http://jayxie.com/mirrors/android-sdk/resources/articles/on-screen-inputs.html
And a tutorial
http://android-developers.blogspot.co.uk/2009/04/creating-input-method.html
There are plenty more out there, I could go on for pages - do your research first!