安全上下文
此特征只可用于
安全上下文
(HTTPS),在某些或所有
支持浏览器
.
keys()
方法在
XRInputSourceArray
interface returns a
JavaScript
iterator
which can then be used to iterate over the keys used to reference each item in the array of input sources.
xrInputSourceArray.keys();
None.
A JavaScript
iterator
that can be used to walk through the keys for each entry in the list of input sources. The values returned by the iterator are the indexes of each entry in the list; that is, the numbers 0, 1, 2, and so forth through the index of the last item in the list.
This example snippet gets the list of inputs for a session and tries to handle each type of input device it supports using.
for (const inputIdx of xrSession.inputSources.keys()) {
/* the keys are the indexes into the list of inputs */
checkInput(xrSession.inputSources[inputIdx]);
}
这里,
for...of
is used to iterate over each of the keys. For each key, the input is retrieved using the index with array notation:
xrSession.inputSources[inputIdx]
.
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebXR 设备 API
The definition of 'XRInputSourceArray' in that specification. 1 |
工作草案 |
XRInputSourceArray
interface
|
[1]
见
Iterator-like methods
in
Information contained in a WebIDL file
for information on how an
iterable
declaration in an interface definition causes
entries()
,
forEach()
,
keys()
,和
values()
methods to be exposed from objects that implement the interface.
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
keys
|
Chrome 79 | Edge 79 | Firefox No | IE No | Opera No | Safari No | WebView Android No | Chrome Android 79 | Firefox Android No | Opera Android No | Safari iOS No | Samsung Internet Android 11.2 |
完整支持
不支持
XRInputSourceArray
Navigator.xr
WebGLRenderingContext.makeXRCompatible()
XR
XRBoundedReferenceSpace
XRFrame
XRInputSource
XRInputSourceEvent
XRInputSourcesChangeEvent
XRPose
XRReferenceSpace
XRReferenceSpaceEvent
XRRenderState
XRRigidTransform
XRSession
XRSessionEvent
XRSpace
XRView
XRViewerPose
XRViewport
XRWebGLLayer