Updated keydown function to properly allow toggling.