Added preventDefault and stopPropagation to keyboard event handling (to prevent the browser from scrolling in response to keystrokes).