Skip to content
Enact

Exports the spotlightspotlight.Spotlight object used for controlling spotlight behavior and the spotlightspotlight.Spotlight.getDirection function for mapping a keycode to a spotlight direction.

The default export is spotlightspotlight.Spotlight.

Provides 5-way navigation and focus support

import Spotlight from '@enact/Spotlight';

// get the currently focused component
const current = Spotlight.getCurrent();

// focus an element by CSS selector
Spotlight.focus('.my-custom-class');

// is `current` focusable?
const isFocused = Spotlight.isSpottable(current);
getDirection( keyCode )  String  |  any

Translates keyCodes into 5-way direction descriptions (e.g. 'down')

1 Param
keyCodeNumber

Key code to analyze

Returns
String | any

One of 'up', 'down', 'left', 'right' or false if not a direction key