fix duplicate keydown handler
refactor char count js
un-refactor js into a single function