Moved code from KeyboardStateScroller project