To improve performance and memory usage:
```javascript
var speedButtonAnchor = state.videoSpeedControl.el.children('a');

state.videoSpeedControl.videoSpeedsEl.on('keydown', 'a.speed_link', function (event) {
    event.preventDefault();
    event.stopImmediatePropagation();

    var el = state.videoSpeedControl.el,
        index = $(event.currentTarget).parent().index();
    
    switch (event.keyCode) {
        // Scroll up menu, wrapping at the top. Keep menu open.
        case KEY.UP:
            _previousSpeedLink(speedLinks, index).focus();
            break;
        // Scroll down  menu, wrapping at the bottom. Keep menu
        // open.
        case KEY.DOWN:
            _nextSpeedLink(speedLinks, index).focus();
            break;
        // Close menu.
        case KEY.TAB:
           el.removeClass('open');
        break;
        // Close menu, give focus to speed control and change
        // speed.
        case KEY.ENTER:
        case KEY.SPACE:
            el.removeClass('open');
            speedButtonAnchor.focus();
            state.videoSpeedControl.changeVideoSpeed(event);
            break;
        // Close menu and give focus to speed control.
        case KEY.ESCAPE:
            el.removeClass('open');
            speedButtonAnchor.focus();
            break;
    }
});
```