nx.js
Classes

Navigator

The Navigator interface represents the state and the identity of the user agent. It allows scripts to query it and to register themselves to carry on some activities.

A Navigator instance can be retrieved by accessing the global navigator property.

See

https://developer.mozilla.org/docs/Web/API/Navigator

Accessors

maxTouchPoints

get maxTouchPoints(): number

Returns the maximum number of simultaneous touch contact points are supported by the current device.

Example

16

See

https://developer.mozilla.org/docs/Web/API/Navigator/maxTouchPoints

Returns

number


platform

get platform(): string

Identifies the platform on which the application is running.

Example

"Horizon arm64"

See

https://developer.mozilla.org/docs/Web/API/Navigator/platform

Returns

string


userAgent

get userAgent(): string

The value used for the User-Agent request header for HTTP requests initiated with fetch().

Example

"my-app/0.0.1 (Switch; en-us; rv:14.1.2|AMS 1.5.4|E) nx.js/0.0.18"

See

https://developer.mozilla.org/docs/Web/API/Navigator/userAgent

Returns

string


virtualKeyboard

get virtualKeyboard(): VirtualKeyboard

A VirtualKeyboard instance to show or hide the virtual keyboard programmatically, and get the current position and size of the virtual keyboard.

See

https://developer.mozilla.org/docs/Web/API/Navigator/virtualKeyboard

Returns

VirtualKeyboard

Methods

getBattery()

getBattery(): Promise<BatteryManager>

Returns a promise which is resolved to a BatteryManager instance.

Returns

Promise<BatteryManager>

See

https://developer.mozilla.org/docs/Web/API/Navigator/getBattery


getGamepads()

getGamepads(): (null | Gamepad)[]

Returns an array of Gamepad objects, one for each gamepad connected to the device.

The indicies of the gamepads array map to the paired controller numbers assigned by the system. Index 0 is the first controller, index 1 is the second controller, and so on.

Index 0 is a special case, which represents input from both the first controller as well as the handheld mode controller.

The gamepads array contains 8 entries, so up to 8 controllers can be connected to the device at a time. Disconnected controllers will have null values in the array.

Returns

(null | Gamepad)[]

Example

if (navigator.getGamepads()[0].buttons[0].pressed) {
  console.log('Button B is pressed on the first controller');
}

See

https://developer.mozilla.org/docs/Web/API/Navigator/getGamepads


vibrate()

vibrate(pattern): boolean

Vibrates the main gamepad for the specified number of milliseconds or pattern.

If a vibration pattern is already in progress when this method is called, the previous pattern is halted and the new one begins instead.

Parameters

ParameterTypeDescription
patternnumber | Vibration | (number | Vibration)[]Provides a pattern of vibration and pause intervals. Each value indicates a number of milliseconds to vibrate or pause, in alternation. You may provide either a single value (to vibrate once for that many milliseconds) or an array of values to alternately vibrate, pause, then vibrate again.

Returns

boolean

Example

// Vibrate for 200ms with the default amplitude/frequency values
navigator.vibrate(200);
 
// Vibrate 'SOS' in Morse Code
navigator.vibrate([
  100, 30, 100, 30, 100, 30, 200, 30, 200, 30, 200, 30, 100, 30, 100, 30, 100,
]);
 
// Specify amplitude/frequency values for the vibration
navigator.vibrate({
  duration: 500,
  lowAmp: 0.2
  lowFreq: 160,
  highAmp: 0.6,
  highFreq: 500
});

See

https://developer.mozilla.org/docs/Web/API/Navigator/vibrate

On this page