Scroll input to end when new group is added

In Chrome input is not scrolled when text overflows if you set
caret position on a text that is outside of current view. Setting
input.scrollLeft to scrollWidth does the trick - it scrolls input
to the end.

For now doing this only when new group added - other usages of
this trick should be researched.
Refactoring

- replaced .caret() calls with getCaretPos/setCaretPos where possible
- replaced all .val() calls with getValue/setValue
- refactored smart caret positioning code
Refactor

- remove old commented code
- use *constants* for all keycodes
- remove unused variables
- remove/rewrite try/catch blocks