implemented viewport restriction and viewport based scrolling for
keyboard