Issue #482

- Added basic support for Home and End buttons (go to beginning/end of current line).
- Fixed the problem with divide/multiplication by 2 being needed at odd places.
- Fix the behavior of Up and Down keys to move the cursor correctly (or at least more correct than it was before).