Fixed a few keyboard related bugs and a selection API bug.