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
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
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
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
Methods
getBattery()
getBattery(): Promise
<BatteryManager
>
Returns a promise which is resolved to a BatteryManager instance.
Returns
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
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
Parameter | Type | Description |
---|---|---|
pattern | number | 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
See
https://developer.mozilla.org/docs/Web/API/Navigator/vibrate