Implemented completion selection

The first found completion can now be filled in by pressing enter when
a completion displayed. Split code for keyup and keydown handlers