Fixed ctrl+A selection, keyboard selection

Previously, each time the keyup callback function was called, the selection was reset to only where the carat was (start and end of selection being the same). To enable use of ctrl+A and shift+right/shift+left to do selection, the end of selection also had to be saved.

To do this, another function from Diego Perini <dperini@nwbox.com> was added to get the selection end, and this was used in the keyup function.

Note: shift+left to selection more than one character still appears to not work.