Compartir a través de


WinJS.UI.XYFocus.keyCodeMap property

Gets or sets an object that specifies the key codes used to move between focusable HTML elements.

Syntax

var keyCodeMap = WinJS.UI.XYFocus.keyCodeMap;
WinJS.UI.XYFocus.keyCodeMap = keyCodeMap;

Property value

Type: ****

An object with this structure:

Property Description

up

Array

An array of Number objects that specify the key codes that move focus in the up direction.

left

Array

An array of Number objects that specify the key codes that move focus in the left direction.

down

Array

An array of Number objects that specify the key codes that move focus in the down direction.

right

Array

An array of Number objects that specify the key codes that move focus in the right direction.

 

Tip  To obtain the numeric value of a key, you can use the WinJS.Utilities.Key enumeration. See the example below.

 

Remarks

XYFocus automatically maps by default to the arrow keys on the keyboard. This mapping can be changed using keyCodeMap as shown in the example below.

Caution  As of Windows Library for JavaScript (WinJS) 4.0, the default mapping will change to the directional keys on the Xbox gamepad and remote control only. The keyboard arrow keys will no longer be defaults.

 

Examples

This example enables the user to navigate with the w, s, a, and d keys in addition to the default mappings.

WinJS.UI.XYFocus.keyCodeMap.up.push(WinJS.Utilities.Key.w); 
WinJS.UI.XYFocus.keyCodeMap.down.push(WinJS.Utilities.Key.s); 
WinJS.UI.XYFocus.keyCodeMap.left.push(WinJS.Utilities.Key.a); 
WinJS.UI.XYFocus.keyCodeMap.right.push(WinJS.Utilities.Key.d); 

Requirements

Minimum WinJS version

WinJS 3.0

Namespace

WinJS.UI.XYFocus

See also

WinJS.UI.XYFocus