Update _handleKeyDown to reflect previous changes and perform better