Implemented keyboard thread callback mechanism

This also adds some implementations of the console api.