repo_id
stringlengths 22
103
| file_path
stringlengths 41
147
| content
stringlengths 181
193k
| __index_level_0__
int64 0
0
|
---|---|---|---|
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/polygonoffset/index.md | ---
title: "WebGLRenderingContext: polygonOffset() method"
short-title: polygonOffset()
slug: Web/API/WebGLRenderingContext/polygonOffset
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.polygonOffset
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.polygonOffset()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) specifies the scale factors and
units to calculate depth values.
The offset is added before the depth test is performed and before the value is written
into the depth buffer.
## Syntax
```js-nolint
polygonOffset(factor, units)
```
### Parameters
- `factor`
- : A {{domxref("WebGL_API/Types", "GLfloat")}} which sets the scale factor for the variable depth offset
for each polygon. The default value is 0.
- `units`
- : A {{domxref("WebGL_API/Types", "GLfloat")}} which sets the multiplier by which an
implementation-specific value is multiplied with to create a constant depth offset.
The default value is 0.
### Return value
None ({{jsxref("undefined")}}).
## Examples
The polygon offset fill is disabled by default. To enable or disable polygon offset
fill, use the {{domxref("WebGLRenderingContext.enable", "enable()")}} and
{{domxref("WebGLRenderingContext.disable", "disable()")}} methods with the argument
`gl.POLYGON_OFFSET_FILL`.
```js
gl.enable(gl.POLYGON_OFFSET_FILL);
gl.polygonOffset(2, 3);
```
To check the current polygon offset factor or units, query the
`POLYGON_OFFSET_FACTOR` and `POLYGON_OFFSET_UNITS` constants.
```js
gl.getParameter(gl.POLYGON_OFFSET_FACTOR); // 2
gl.getParameter(gl.POLYGON_OFFSET_UNITS); // 3
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.depthFunc()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/buffersubdata/index.md | ---
title: "WebGLRenderingContext: bufferSubData() method"
short-title: bufferSubData()
slug: Web/API/WebGLRenderingContext/bufferSubData
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.bufferSubData
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.bufferSubData()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) updates a subset of a buffer
object's data store.
## Syntax
```js-nolint
// WebGL1
bufferSubData(target, offset)
bufferSubData(target, offset, srcData)
// WebGL2
bufferSubData(target, dstByteOffset, srcOffset)
bufferSubData(target, dstByteOffset, srcData, srcOffset)
bufferSubData(target, dstByteOffset, srcData, srcOffset, length)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values:
- `gl.ARRAY_BUFFER`
- : Buffer containing vertex attributes, such as
vertex coordinates, texture coordinate data, or vertex color data.
- `gl.ELEMENT_ARRAY_BUFFER`
- : Buffer used for element indices.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.COPY_READ_BUFFER`
- : Buffer for copying from one buffer object to another.
- `gl.COPY_WRITE_BUFFER`
- : Buffer for copying from one buffer object to another.
- `gl.TRANSFORM_FEEDBACK_BUFFER`
- : Buffer for transform feedback operations.
- `gl.UNIFORM_BUFFER`
- : Buffer used for storing uniform blocks.
- `gl.PIXEL_PACK_BUFFER`
- : Buffer used for pixel transfer operations.
- `gl.PIXEL_UNPACK_BUFFER`
- : Buffer used for pixel transfer operations.
- `dstByteOffset`
- : A {{domxref("WebGL_API/Types", "GLintptr")}} specifying an offset in bytes where the data replacement
will start.
- `srcData` {{optional_inline}}
- : An {{jsxref("ArrayBuffer")}}, {{jsxref("SharedArrayBuffer")}}, a {{jsxref("DataView")}}, or a {{jsxref("TypedArray")}}
that will be copied into the data store.
- `srcOffset`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the element index offset where to start reading
the buffer.
- `length` {{optional_inline}}
- : A {{domxref("WebGL_API/Types", "GLuint")}} defaulting to 0.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
- A `gl.INVALID_VALUE` error is thrown if the data would be written past
the end of the buffer or if `data` is `null`.
- A `gl.INVALID_ENUM` error is thrown if `target` is not one of
the allowed enums.
## Examples
### Using `bufferSubData`
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW);
gl.bufferSubData(gl.ARRAY_BUFFER, 512, data);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createBuffer()")}}
- {{domxref("WebGLRenderingContext.bufferData()")}}
- Other buffers: {{domxref("WebGLFramebuffer")}}, {{domxref("WebGLRenderbuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/linkprogram/index.md | ---
title: "WebGLRenderingContext: linkProgram() method"
short-title: linkProgram()
slug: Web/API/WebGLRenderingContext/linkProgram
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.linkProgram
---
{{APIRef("WebGL")}}
The {{domxref("WebGLRenderingContext")}} interface's
**`linkProgram()`** method links a given
{{domxref("WebGLProgram")}}, completing the process of preparing the GPU code for the
program's fragment and vertex shaders.
## Syntax
```js-nolint
linkProgram(program)
```
### Parameters
- `program`
- : The {{domxref("WebGLProgram")}} to link.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
const program = gl.createProgram();
// Attach pre-existing shaders
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
const info = gl.getProgramInfoLog(program);
throw new Error(`Could not compile WebGL program. \n\n${info}`);
}
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createProgram()")}}
- {{domxref("WebGLRenderingContext.deleteProgram()")}}
- {{domxref("WebGLRenderingContext.isProgram()")}}
- {{domxref("WebGLRenderingContext.useProgram()")}}
- {{domxref("WebGLRenderingContext.validateProgram()")}}
- {{domxref("WebGLRenderingContext.getProgramParameter()")}}
- {{domxref("WebGLRenderingContext.getProgramInfoLog()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/isbuffer/index.md | ---
title: "WebGLRenderingContext: isBuffer() method"
short-title: isBuffer()
slug: Web/API/WebGLRenderingContext/isBuffer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.isBuffer
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.isBuffer()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns `true` if the
passed {{domxref("WebGLBuffer")}} is valid and `false` otherwise.
## Syntax
```js-nolint
isBuffer(buffer)
```
### Parameters
- `buffer`
- : A {{domxref("WebGLBuffer")}} to check.
### Return value
A {{domxref("WebGL_API/Types", "GLboolean")}} indicating whether or not the buffer is valid.
## Examples
### Creating a buffer
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const buffer = gl.createBuffer();
gl.isBuffer(buffer);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindBuffer()")}}
- {{domxref("WebGLRenderingContext.createBuffer()")}}
- {{domxref("WebGLRenderingContext.deleteBuffer()")}}
- Other buffers: {{domxref("WebGLFramebuffer")}}, {{domxref("WebGLRenderbuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/compileshader/index.md | ---
title: "WebGLRenderingContext: compileShader() method"
short-title: compileShader()
slug: Web/API/WebGLRenderingContext/compileShader
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.compileShader
---
{{APIRef("WebGL")}}
The **WebGLRenderingContext.compileShader()** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) compiles a GLSL shader into binary
data so that it can be used by a {{domxref("WebGLProgram")}}.
## Syntax
```js-nolint
compileShader(shader)
```
### Parameters
- `shader`
- : A fragment or vertex {{domxref("WebGLShader")}}.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
const shader = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(shader, shaderSource);
gl.compileShader(shader);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLProgram")}}
- {{domxref("WebGLShader")}}
- {{domxref("WebGLRenderingContext.attachShader()")}}
- {{domxref("WebGLRenderingContext.createProgram()")}}
- {{domxref("WebGLRenderingContext.createShader()")}}
- {{domxref("WebGLRenderingContext.deleteProgram()")}}
- {{domxref("WebGLRenderingContext.deleteShader()")}}
- {{domxref("WebGLRenderingContext.detachShader()")}}
- {{domxref("WebGLRenderingContext.getAttachedShaders()")}}
- {{domxref("WebGLRenderingContext.getProgramParameter()")}}
- {{domxref("WebGLRenderingContext.getProgramInfoLog()")}}
- {{domxref("WebGLRenderingContext.getShaderParameter()")}}
- {{domxref("WebGLRenderingContext.getShaderPrecisionFormat()")}}
- {{domxref("WebGLRenderingContext.getShaderInfoLog()")}}
- {{domxref("WebGLRenderingContext.getShaderSource()")}}
- {{domxref("WebGLRenderingContext.isProgram()")}}
- {{domxref("WebGLRenderingContext.isShader()")}}
- {{domxref("WebGLRenderingContext.linkProgram()")}}
- {{domxref("WebGLRenderingContext.shaderSource()")}}
- {{domxref("WebGLRenderingContext.useProgram()")}}
- {{domxref("WebGLRenderingContext.validateProgram()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getshaderinfolog/index.md | ---
title: "WebGLRenderingContext: getShaderInfoLog() method"
short-title: getShaderInfoLog()
slug: Web/API/WebGLRenderingContext/getShaderInfoLog
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getShaderInfoLog
---
{{APIRef("WebGL")}}
The **WebGLRenderingContext.getShaderInfoLog** returns the information log
for the specified {{domxref("WebGLShader")}} object. It contains warnings, debugging and
compile information.
## Syntax
```js-nolint
getShaderInfoLog(shader)
```
### Parameters
- `shader`
- : A {{domxref("WebGLShader")}} to query.
### Return value
A string that contains diagnostic messages, warning messages, and
other information about the last compile operation. When a {{domxref("WebGLShader")}}
object is initially created, its information log will be a string of length 0.
## Examples
### Checking compilation messages
```js
/* load shader source code. */
gl.shaderSource(shader, shaderCode);
/* compile shader source code. */
gl.compileShader(shader);
const message = gl.getShaderInfoLog(shader);
if (message.length > 0) {
/* message may be an error or a warning */
throw message;
}
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getShaderParameter()")}} – used with
`gl.COMPILE_STATUS` to check for a failed compile.
- {{domxref("WebGLRenderingContext.getError()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/samplecoverage/index.md | ---
title: "WebGLRenderingContext: sampleCoverage() method"
short-title: sampleCoverage()
slug: Web/API/WebGLRenderingContext/sampleCoverage
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.sampleCoverage
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.sampleCoverage()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) specifies multi-sample coverage
parameters for anti-aliasing effects.
## Syntax
```js-nolint
sampleCoverage(value, invert)
```
### Parameters
- `value`
- : A {{domxref("WebGL_API/Types", "GLclampf")}} which sets a single floating-point coverage value clamped
to the range \[0,1]. The default value is 1.0.
- `invert`
- : A {{domxref("WebGL_API/Types", "GLboolean")}} which sets whether or not the coverage masks should be
inverted. The default value is `false`.
### Return value
None ({{jsxref("undefined")}}).
## Examples
Multi-sampling is disabled by default. To enable or disable multi-sampling, use the
{{domxref("WebGLRenderingContext.enable", "enable()")}} and
{{domxref("WebGLRenderingContext.disable", "disable()")}} methods with the argument
`gl.SAMPLE_COVERAGE` and `gl.SAMPLE_ALPHA_TO_COVERAGE`.
```js
gl.enable(gl.SAMPLE_COVERAGE);
gl.sampleCoverage(0.5, false);
```
To check the sample coverage values, query the `SAMPLE_COVERAGE_VALUE` and
`SAMPLE_COVERAGE_INVERT` constants.
```js
gl.getParameter(gl.SAMPLE_COVERAGE_VALUE); // 0.5
gl.getParameter(gl.SAMPLE_COVERAGE_INVERT); // false
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("HTMLCanvasElement.getContext()")}} – `antialias` parameter for
the context.
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/clearcolor/index.md | ---
title: "WebGLRenderingContext: clearColor() method"
short-title: clearColor()
slug: Web/API/WebGLRenderingContext/clearColor
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.clearColor
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.clearColor()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specifies the color values used
when clearing color buffers.
This specifies what color values to use when calling the
{{domxref("WebGLRenderingContext.clear", "clear()")}} method. The values are clamped
between 0 and 1.
## Syntax
```js-nolint
clearColor(red, green, blue, alpha)
```
### Parameters
- `red`
- : A {{domxref("WebGL_API/Types", "GLclampf")}} specifying the red color value used when the color buffers
are cleared. Default value: 0.
- `green`
- : A {{domxref("WebGL_API/Types", "GLclampf")}} specifying the green color value used when the color
buffers are cleared. Default value: 0.
- `blue`
- : A {{domxref("WebGL_API/Types", "GLclampf")}} specifying the blue color value used when the color
buffers are cleared. Default value: 0.
- `alpha`
- : A {{domxref("WebGL_API/Types", "GLclampf")}} specifying the alpha (transparency) value used when the
color buffers are cleared. Default value: 0.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.clearColor(1, 0.5, 0.5, 3);
```
To get the current clear color, query the `COLOR_CLEAR_VALUE` constant which
returns a {{jsxref("Float32Array")}}.
```js
gl.getParameter(gl.COLOR_CLEAR_VALUE);
// Float32Array[1, 0.5, 0.5, 1]
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.clear()")}}
- {{domxref("WebGLRenderingContext.clearDepth()")}}
- {{domxref("WebGLRenderingContext.clearStencil()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getactiveattrib/index.md | ---
title: "WebGLRenderingContext: getActiveAttrib() method"
short-title: getActiveAttrib()
slug: Web/API/WebGLRenderingContext/getActiveAttrib
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getActiveAttrib
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getActiveAttrib()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) returns a
{{domxref("WebGLActiveInfo")}} object containing size, type, and name of a vertex
attribute. It is generally used when querying unknown attributes either for debugging or
generic library creation.
## Syntax
```js-nolint
getActiveAttrib(program, index)
```
### Parameters
- `program`
- : A {{domxref("WebGLProgram")}} containing the vertex attribute.
- `index`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the index of the vertex attribute to get. This
value is an index 0 to N - 1 as returned
by {{domxref("WebGLRenderingContext.getProgramParameter",
"gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES)")}}.
### Return value
A {{domxref("WebGLActiveInfo")}} object.
## Examples
```js
const numAttribs = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
for (let i = 0; i < numAttribs; ++i) {
const info = gl.getActiveAttrib(program, i);
console.log("name:", info.name, "type:", info.type, "size:", info.size);
}
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLActiveInfo")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getvertexattrib/index.md | ---
title: "WebGLRenderingContext: getVertexAttrib() method"
short-title: getVertexAttrib()
slug: Web/API/WebGLRenderingContext/getVertexAttrib
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getVertexAttrib
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getVertexAttrib()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) returns information about a vertex
attribute at a given position.
## Syntax
```js-nolint
getVertexAttrib(index, pname)
```
### Parameters
- `index`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the index of the vertex attribute.
- `pname`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the information to query. Possible values:
- `gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING`
- : Returns the currently bound {{domxref("WebGLBuffer")}}.
- `gl.VERTEX_ATTRIB_ARRAY_ENABLED`
- : Returns a {{domxref("WebGL_API/Types", "GLboolean")}} that is `true` if the vertex attribute is enabled at this `index`. Otherwise `false`.
- `gl.VERTEX_ATTRIB_ARRAY_SIZE`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}}
indicating the size of an element of the vertex array.
- `gl.VERTEX_ATTRIB_ARRAY_STRIDE`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}}
indicating the number of bytes between successive elements in the array. 0 means
that the elements are sequential.
- `gl.VERTEX_ATTRIB_ARRAY_TYPE`
- : Returns a {{domxref("WebGL_API/Types", "GLenum")}}
representing the array type. One of
- `gl.BYTE`
- `gl.UNSIGNED_BYTE`
- `gl.SHORT`,
- `gl.UNSIGNED_SHORT`
- `gl.FLOAT`
- `gl.VERTEX_ATTRIB_ARRAY_NORMALIZED`
- : Returns a
{{domxref("WebGL_API/Types", "GLboolean")}} that is true if fixed-point data types are normalized for
the vertex attribute array at the given `index`.
- `gl.CURRENT_VERTEX_ATTRIB`
- : Returns a {{jsxref("Float32Array")}}
(with 4 elements) representing the current value of the vertex attribute at the
given `index`.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.VERTEX_ATTRIB_ARRAY_INTEGER`
- : Returns a
{{domxref("WebGL_API/Types", "GLboolean")}} indicating whether an integer data type is in
the vertex attribute array at the given `index`.
- `gl.VERTEX_ATTRIB_ARRAY_DIVISOR`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}}
describing the frequency divisor used for instanced rendering.
When using the {{domxref("ANGLE_instanced_arrays")}} extension:
- `ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE`
- : Returns a
{{domxref("WebGL_API/Types", "GLint")}} describing the frequency divisor used for instanced
rendering.
### Return value
Returns the requested vertex attribute information (as specified with
`pname`).
## Examples
```js
gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getVertexAttribOffset()")}}
- {{domxref("ANGLE_instanced_arrays")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/createrenderbuffer/index.md | ---
title: "WebGLRenderingContext: createRenderbuffer() method"
short-title: createRenderbuffer()
slug: Web/API/WebGLRenderingContext/createRenderbuffer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.createRenderbuffer
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.createRenderbuffer()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) creates and initializes a
{{domxref("WebGLRenderbuffer")}} object.
## Syntax
```js-nolint
createRenderbuffer()
```
### Parameters
None.
### Return value
A {{domxref("WebGLRenderbuffer")}} object that stores data such an image, or can be
source or target of an rendering operation.
## Examples
### Creating a render buffer
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const renderBuffer = gl.createRenderbuffer();
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.deleteRenderbuffer()")}}
- {{domxref("WebGLRenderingContext.isRenderbuffer()")}}
- Other buffers: {{domxref("WebGLBuffer")}}, {{domxref("WebGLFramebuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/finish/index.md | ---
title: "WebGLRenderingContext: finish() method"
short-title: finish()
slug: Web/API/WebGLRenderingContext/finish
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.finish
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.finish()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) blocks execution until all
previously called commands are finished.
## Syntax
```js-nolint
finish()
```
### Parameters
None.
### Return value
None ({{jsxref("undefined")}}).
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.flush()")}}
- [WebGL best practices](/en-US/docs/Web/API/WebGL_API/WebGL_best_practices) (which recommends avoiding `finish()` as it may slow down
your main rendering loop)
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getuniform/index.md | ---
title: "WebGLRenderingContext: getUniform() method"
short-title: getUniform()
slug: Web/API/WebGLRenderingContext/getUniform
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getUniform
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getUniform()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns the value of a uniform
variable at a given location.
## Syntax
```js-nolint
getUniform(program, location)
```
### Parameters
- `program`
- : A {{domxref("WebGLProgram")}} containing the uniform attribute.
- `location`
- : A {{domxref("WebGLUniformLocation")}} object containing the location of the uniform
attribute to get.
### Return value
The returned type depends on the uniform type:
<table class="standard-table">
<thead>
<tr>
<th scope="col">Uniform type</th>
<th scope="col">Returned type</th>
</tr>
</thead>
<tbody>
<tr>
<th colspan="2">WebGL 1 only</th>
</tr>
<tr>
<td><code>boolean</code></td>
<td>{{domxref("WebGL_API/Types", "GLBoolean")}}</td>
</tr>
<tr>
<td><code>int</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
</tr>
<tr>
<td><code>float</code></td>
<td>{{domxref("WebGL_API/Types", "GLfloat")}}</td>
</tr>
<tr>
<td><code>vec2</code></td>
<td>{{jsxref("Float32Array")}} (with 2 elements)</td>
</tr>
<tr>
<td><code>ivec2</code></td>
<td>{{jsxref("Int32Array")}} (with 2 elements)</td>
</tr>
<tr>
<td><code>bvec2</code></td>
<td>
{{jsxref("Array")}} of
{{domxref("WebGL_API/Types", "GLBoolean")}} (with 2
elements)
</td>
</tr>
<tr>
<td><code>vec3</code></td>
<td>{{jsxref("Float32Array")}} (with 3 elements)</td>
</tr>
<tr>
<td><code>ivec3</code></td>
<td>{{jsxref("Int32Array")}} (with 3 elements)</td>
</tr>
<tr>
<td><code>bvec3</code></td>
<td>
{{jsxref("Array")}} of
{{domxref("WebGL_API/Types", "GLBoolean")}} (with 3
elements)
</td>
</tr>
<tr>
<td><code>vec4</code></td>
<td>{{jsxref("Float32Array")}} (with 4 elements)</td>
</tr>
<tr>
<td><code>ivec4</code></td>
<td>{{jsxref("Int32Array")}} (with 4 elements)</td>
</tr>
<tr>
<td><code>bvec4</code></td>
<td>
{{jsxref("Array")}} of
{{domxref("WebGL_API/Types", "GLBoolean")}} (with 4
elements)
</td>
</tr>
<tr>
<td><code>mat2</code></td>
<td>{{jsxref("Float32Array")}} (with 4 elements)</td>
</tr>
<tr>
<td><code>mat3</code></td>
<td>{{jsxref("Float32Array")}} (with 9 elements)</td>
</tr>
<tr>
<td><code>mat4</code></td>
<td>{{jsxref("Float32Array")}} (with 16 elements)</td>
</tr>
<tr>
<td><code>sampler2D</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
</tr>
<tr>
<td><code>samplerCube</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
</tr>
<tr>
<th colspan="2">Additionally available in WebGL 2</th>
</tr>
<tr>
<td><code>uint</code></td>
<td>{{domxref("WebGL_API/Types", "GLuint")}}</td>
</tr>
<tr>
<td><code>uvec2</code></td>
<td>{{jsxref("Uint32Array")}} (with 2 elements)</td>
</tr>
<tr>
<td><code>uvec3</code></td>
<td>{{jsxref("Uint32Array")}} (with 3 elements)</td>
</tr>
<tr>
<td><code>uvec4</code></td>
<td>{{jsxref("Uint32Array")}} (with 4 elements)</td>
</tr>
<tr>
<td><code>mat2x3</code></td>
<td>{{jsxref("Float32Array")}} (with 6 elements)</td>
</tr>
<tr>
<td><code>mat2x4</code></td>
<td>{{jsxref("Float32Array")}} (with 8 elements)</td>
</tr>
<tr>
<td><code>mat3x2</code></td>
<td>{{jsxref("Float32Array")}} (with 6 elements)</td>
</tr>
<tr>
<td><code>mat3x4</code></td>
<td>{{jsxref("Float32Array")}} (with 12 elements)</td>
</tr>
<tr>
<td><code>mat4x2</code></td>
<td>{{jsxref("Float32Array")}} (with 8 elements)</td>
</tr>
<tr>
<td><code>mat4x3</code></td>
<td>{{jsxref("Float32Array")}} (with 12 elements)</td>
</tr>
<tr>
<td>any sampler type</td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
</tr>
</tbody>
</table>
## Examples
```js
const loc = gl.getUniformLocation(program, "u_foobar");
gl.getUniform(program, loc);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLUniformLocation")}}
- {{domxref("WebGLRenderingContext.getActiveUniform()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/blendfunc/index.md | ---
title: "WebGLRenderingContext: blendFunc() method"
short-title: blendFunc()
slug: Web/API/WebGLRenderingContext/blendFunc
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.blendFunc
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.blendFunc()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) defines which function is used for
blending pixel arithmetic.
## Syntax
```js-nolint
blendFunc(sfactor, dfactor)
```
### Parameters
- `sfactor`
- : A {{domxref("WebGL_API.Types")}} specifying a multiplier for the source blending factors. The
default value is `gl.ONE`. For possible values, see below.
- `dfactor`
- : A {{domxref("WebGL_API.Types")}} specifying a multiplier for the destination blending
factors. The default value is `gl.ZERO`. For possible values, see below.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
- If _sfactor_ or _dfactor_ is not one of the listed possible values, a
`gl.INVALID_ENUM` error is thrown.
- If a constant color and a constant alpha value are used together as source and
destination factors, a `gl.INVALID_ENUM` error is thrown.
## Constants
The following constants can be used for _sfactor_ and _dfactor_.
The formula for the blending color can be described like this: color(RGBA) =
(sourceColor \* _sfactor_) + (destinationColor \* _dfactor_). The RGBA
values are between 0 and 1.
In the following table, R<sub>S</sub>, G<sub>S</sub>, B<sub>S</sub>, A<sub>S</sub> represent respectively
the _red_, _green_, _blue_ and _alpha_ component of the source, while
R<sub>D</sub>, G<sub>D</sub>, B<sub>D</sub>, A<sub>D</sub> represent respectively
the _red_, _green_, _blue_ and _alpha_ component of the destination.
Similarly, R<sub>C</sub>, G<sub>C</sub>, B<sub>C</sub>, A<sub>C</sub> represent respectively
the _red_, _green_, _blue_ and _alpha_ component of a constant color. They are all values between 0 and 1, included.
<table class="no-markdown">
<thead>
<tr>
<th scope="col">Constant</th>
<th scope="col">Factor</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>gl.ZERO</code></td>
<td>0,0,0,0</td>
<td>Multiplies all colors by 0.</td>
</tr>
<tr>
<td><code>gl.ONE</code></td>
<td>1,1,1,1</td>
<td>Multiplies all colors by 1.</td>
</tr>
<tr>
<td><code>gl.SRC_COLOR</code></td>
<td>R<sub>S</sub>, G<sub>S</sub>, B<sub>S</sub>, A<sub>S</sub></td>
<td>Multiplies all colors by the source colors.</td>
</tr>
<tr>
<td><code>gl.ONE_MINUS_SRC_COLOR</code></td>
<td>
1-R<sub>S</sub>, 1-G<sub>S</sub>, 1-B<sub>S</sub>, 1-A<sub>S</sub>
</td>
<td>Multiplies all colors by 1 minus each source color.</td>
</tr>
<tr>
<td><code>gl.DST_COLOR</code></td>
<td>R<sub>D</sub>, G<sub>D</sub>, B<sub>D</sub>, A<sub>D</sub></td>
<td>Multiplies all colors by the destination color.</td>
</tr>
<tr>
<td><code>gl.ONE_MINUS_DST_COLOR</code></td>
<td>
1-R<sub>D</sub>, 1-G<sub>D</sub>, 1-B<sub>D</sub>, 1-A<sub>D</sub>
</td>
<td>Multiplies all colors by 1 minus each destination color.</td>
</tr>
<tr>
<td><code>gl.SRC_ALPHA</code></td>
<td>A<sub>S</sub>, A<sub>S</sub>, A<sub>S</sub>, A<sub>S</sub></td>
<td>Multiplies all colors by the source alpha value.</td>
</tr>
<tr>
<td><code>gl.ONE_MINUS_SRC_ALPHA</code></td>
<td>
1-A<sub>S</sub>, 1-A<sub>S</sub>, 1-A<sub>S</sub>, 1-A<sub>S</sub>
</td>
<td>Multiplies all colors by 1 minus the source alpha value.</td>
</tr>
<tr>
<td><code>gl.DST_ALPHA</code></td>
<td>A<sub>D</sub>, A<sub>D</sub>, A<sub>D</sub>, A<sub>D</sub></td>
<td>Multiplies all colors by the destination alpha value.</td>
</tr>
<tr>
<td><code>gl.ONE_MINUS_DST_ALPHA</code></td>
<td>
1-A<sub>D</sub>, 1-A<sub>D</sub>, 1-A<sub>D</sub>, 1-A<sub>D</sub>
</td>
<td>Multiplies all colors by 1 minus the destination alpha value.</td>
</tr>
<tr>
<td><code>gl.CONSTANT_COLOR</code></td>
<td>R<sub>C</sub>, G<sub>C</sub>, B<sub>C</sub>, A<sub>C</sub></td>
<td>Multiplies all colors by a constant color.</td>
</tr>
<tr>
<td><code>gl.ONE_MINUS_CONSTANT_COLOR</code></td>
<td>
1-R<sub>C</sub>, 1-G<sub>C</sub>, 1-B<sub>C</sub>, 1-A<sub>C</sub>
</td>
<td>Multiplies all colors by 1 minus a constant color.</td>
</tr>
<tr>
<td><code>gl.CONSTANT_ALPHA</code></td>
<td>A<sub>C</sub>, A<sub>C</sub>, A<sub>C</sub>, A<sub>C</sub></td>
<td>Multiplies all colors by a constant alpha value.</td>
</tr>
<tr>
<td><code>gl.ONE_MINUS_CONSTANT_ALPHA</code></td>
<td>
1-A<sub>C</sub>, 1-A<sub>C</sub>, 1-A<sub>C</sub>, 1-A<sub>C</sub>
</td>
<td>Multiplies all colors by 1 minus a constant alpha value.</td>
</tr>
<tr>
<td><code>gl.SRC_ALPHA_SATURATE</code></td>
<td>
min(A<sub>S</sub>, 1 - A<sub>D</sub>), min(A<sub>S</sub>, 1 -
A<sub>D</sub>), min(A<sub>S</sub>, 1 - A<sub>D</sub>), 1
</td>
<td>
Multiplies the RGB colors by the smaller of either the source alpha
value or the value of 1 minus the destination alpha value. The alpha
value is multiplied by 1.
</td>
</tr>
</tbody>
</table>
## Examples
To use the blend function, you first have to activate blending with
{{domxref("WebGLRenderingContext.enable()")}} with the argument `gl.BLEND`.
```js
gl.enable(gl.BLEND);
gl.blendFunc(gl.SRC_COLOR, gl.DST_COLOR);
```
To get the current blend function, query the `BLEND_SRC_RGB`,
`BLEND_SRC_ALPHA`, `BLEND_DST_RGB`, and
`BLEND_DST_ALPHA` constants which return one of the blend function constants.
```js
gl.enable(gl.BLEND);
gl.blendFunc(gl.SRC_COLOR, gl.DST_COLOR);
gl.getParameter(gl.BLEND_SRC_RGB) === gl.SRC_COLOR;
// true
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.blendColor()")}}
- {{domxref("WebGLRenderingContext.blendEquation()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/shadersource/index.md | ---
title: "WebGLRenderingContext: shaderSource() method"
short-title: shaderSource()
slug: Web/API/WebGLRenderingContext/shaderSource
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.shaderSource
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.shaderSource()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) sets the source code of a
{{domxref("WebGLShader")}}.
## Syntax
```js-nolint
shaderSource(shader, source)
```
### Parameters
- `shader`
- : A {{domxref("WebGLShader")}} object in which to set the source code.
- `source`
- : A string containing the GLSL source code to set.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
const shader = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(shader, originalSource);
const source = gl.getShaderSource(shader);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createShader()")}}
- {{domxref("WebGLRenderingContext.isShader()")}}
- {{domxref("WebGLRenderingContext.deleteShader()")}}
- {{domxref("WebGLRenderingContext.getShaderSource()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/bindframebuffer/index.md | ---
title: "WebGLRenderingContext: bindFramebuffer() method"
short-title: bindFramebuffer()
slug: Web/API/WebGLRenderingContext/bindFramebuffer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.bindFramebuffer
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.bindFramebuffer()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) binds to the specified target the provided {{domxref("WebGLFramebuffer")}}, or, if the `framebuffer` argument is null, the default {{domxref("WebGLFramebuffer")}}, which is associated with the canvas rendering context.
## Syntax
```js-nolint
bindFramebuffer(target, framebuffer)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values:
- `gl.FRAMEBUFFER`
- : Collection buffer data storage of color, alpha,
depth and stencil buffers used as both a destination for drawing and as a source for reading (see below).
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.DRAW_FRAMEBUFFER`
- : Used as a destination for drawing operations such as `gl.draw*`, `gl.clear*` and `gl.blitFramebuffer`.
- `gl.READ_FRAMEBUFFER`
- : Used as a source for reading operations such as `gl.readPixels` and `gl.blitFramebuffer`.
- `framebuffer`
- : A {{domxref("WebGLFramebuffer")}} object to bind, or [`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null) for binding the {{domxref("HTMLCanvasElement")}} or {{domxref("OffscreenCanvas")}} object associated with the rendering context.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
A `gl.INVALID_ENUM` error is thrown if `target` is not
`gl.FRAMEBUFFER`, `gl.DRAW_FRAMEBUFFER`, or
`gl.READ_FRAMEBUFFER`.
## Examples
### Binding a frame buffer
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const framebuffer = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
```
### Getting current bindings
To check the current frame buffer binding, query the `FRAMEBUFFER_BINDING`
constant.
```js
gl.getParameter(gl.FRAMEBUFFER_BINDING);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createFramebuffer()")}}
- {{domxref("WebGLRenderingContext.deleteFramebuffer()")}}
- {{domxref("WebGLRenderingContext.isFramebuffer()")}}
- Other buffers: {{domxref("WebGLBuffer")}}, {{domxref("WebGLRenderbuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/blendcolor/index.md | ---
title: "WebGLRenderingContext: blendColor() method"
short-title: blendColor()
slug: Web/API/WebGLRenderingContext/blendColor
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.blendColor
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.blendColor()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) is used to set the source and
destination blending factors.
## Syntax
```js-nolint
blendColor(red, green, blue, alpha)
```
### Parameters
- `red`
- : A {{domxref("WebGL_API/Types", "GLclampf")}} for the red component in the range of 0 to 1. Default value is 0.
- `green`
- : A {{domxref("WebGL_API/Types", "GLclampf")}} for the green component in the range of 0 to 1. Default value is 0.
- `blue`
- : A {{domxref("WebGL_API/Types", "GLclampf")}} for the blue component in the range of 0 to 1. Default value is 0.
- `alpha`
- : A {{domxref("WebGL_API/Types", "GLclampf")}} for the alpha component (transparency) in the range of 0.
to 1. Default value is 0.
### Return value
None ({{jsxref("undefined")}}).
## Examples
To set the blend color, use:
```js
gl.blendColor(0, 0.5, 1, 1);
```
To get the blend color, query the `BLEND_COLOR` constant which returns a
{{jsxref("Float32Array")}}.
```js
gl.getParameter(gl.BLEND_COLOR);
// Float32Array[0, 0.5, 1, 1]
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.blendEquation()")}}
- {{domxref("WebGLRenderingContext.blendFunc()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/vertexattribpointer/index.md | ---
title: "WebGLRenderingContext: vertexAttribPointer() method"
short-title: vertexAttribPointer()
slug: Web/API/WebGLRenderingContext/vertexAttribPointer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.vertexAttribPointer
---
{{APIRef("WebGL")}}
The
**`WebGLRenderingContext.vertexAttribPointer()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) binds the buffer currently bound
to `gl.ARRAY_BUFFER` to a generic vertex attribute of the current vertex
buffer object and specifies its layout.
## Syntax
```js-nolint
vertexAttribPointer(index, size, type, normalized, stride, offset)
```
### Parameters
- `index`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the index of the vertex attribute that is to be
modified.
- `size`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the number of components per vertex attribute.
Must be 1, 2, 3, or 4.
- `type`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the data type of each component in the array.
Possible values:
- `gl.BYTE`: signed 8-bit integer, with values in \[-128, 127]
- `gl.SHORT`: signed 16-bit integer, with values in \[-32768, 32767]
- `gl.UNSIGNED_BYTE`: unsigned 8-bit integer, with values in \[0, 255]
- `gl.UNSIGNED_SHORT`: unsigned 16-bit integer, with values in \[0,65535]
- `gl.FLOAT`: 32-bit IEEE floating point number
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.HALF_FLOAT`: 16-bit IEEE floating point number
- `gl.INT`: 32-bit signed binary integer
- `gl.UNSIGNED_INT`: 32-bit unsigned binary integer
- `gl.INT_2_10_10_10_REV`: 32-bit signed integer with values in \[-512, 511]
- `gl.UNSIGNED_INT_2_10_10_10_REV`: 32-bit unsigned integer with values in \[0, 1023]
- `normalized`
- : A {{domxref("WebGL_API/Types", "GLboolean")}} specifying whether integer data values should be
normalized into a certain range when being cast to a float.
- For types `gl.BYTE` and `gl.SHORT`, normalizes the values
to \[-1, 1] if true.
- For types `gl.UNSIGNED_BYTE` and `gl.UNSIGNED_SHORT`,
normalizes the values to \[0, 1] if true.
- For types `gl.FLOAT` and `gl.HALF_FLOAT`, this parameter
has no effect.
- `stride`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the offset in bytes between the beginning of
consecutive vertex attributes. Cannot be negative or larger than 255. If stride is 0, the
attribute is assumed to be tightly packed, that is, the attributes are not interleaved
but each attribute is in a separate block, and the next vertex' attribute follows
immediately after the current vertex.
- `offset`
- : A {{domxref("WebGL_API/Types", "GLintptr")}} specifying an offset in bytes of the first component in
the vertex attribute array. Must be a multiple of the byte length
of `type`.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
- A `gl.INVALID_VALUE` error is thrown if `stride` or `offset` are negative.
- A `gl.INVALID_OPERATION` error is thrown if `stride` and
`offset` are not multiples of the size of the data type.
- A `gl.INVALID_OPERATION` error is thrown if no WebGLBuffer is bound to
the ARRAY_BUFFER target.
- When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, a
`gl.INVALID_OPERATION` error is thrown if this vertex attribute is defined
as an integer in the vertex shader (e.g. `uvec4` or `ivec4`,
instead of `vec4`).
## Description
Let's assume we want to render some 3D geometry, and for that we will need to supply
our vertices to the Vertex Shader. Each vertex has a few attributes, like position,
normal vector, or texture coordinate, that are defined in an {{jsxref("ArrayBuffer")}}
and will be supplied to the Vertex Buffer Object (VBO). First, we need to bind the
{{domxref("WebGLBuffer")}} we want to use to `gl.ARRAY_BUFFER`, then, with
this method, `gl.vertexAttribPointer()`, we specify in what order the
attributes are stored, and what data type they are in. In addition, we need to include
the stride, which is the total byte length of all attributes for one vertex. Also, we
have to call {{domxref("WebGLRenderingContext/enableVertexAttribArray",
"gl.enableVertexAttribArray()")}} to tell WebGL that this attribute should be filled
with data from our array buffer.
Usually, your 3D geometry is already in a certain binary format, so you need to read
the specification of that specific format to figure out the memory layout. However, if
you are designing the format yourself, or your geometry is in text files (like [Wavefront .obj files](https://en.wikipedia.org/wiki/Wavefront_.obj_file)) and
must be converted into an `ArrayBuffer` at runtime, you have free choice on
how to structure the memory. For highest performance, [interleave](https://en.wikipedia.org/wiki/Interleaved_memory) the attributes
and use the smallest data type that still accurately represents your geometry.
The maximum number of vertex attributes depends on the graphics card, and you can call
`gl.getParameter(gl.MAX_VERTEX_ATTRIBS)` to get this value. On high-end
graphics cards, the maximum is 16, on lower-end graphics cards, the value will be lower.
### Attribute index
For each attribute, you must specify its index. This is independent from the location
inside the array buffer, so your attributes can be sent in a different order than how
they are stored in the array buffer. You have two options:
- Either you specify the index yourself. In this case, you call
{{domxref("WebGLRenderingContext.bindAttribLocation()", "gl.bindAttribLocation()")}}
to connect a named attribute from the vertex shader to the index you want to use. This
must be done before calling {{domxref("WebGLRenderingContext.linkProgram()",
"gl.linkProgram()")}}. You can then provide this same index to
`gl.vertexAttribPointer()`.
- Alternatively, you use the index that is assigned by the graphics card when
compiling the vertex shader. Depending on the graphics card, the index will vary, so
you must call {{domxref("WebGLRenderingContext.getAttribLocation()",
"gl.getAttribLocation()")}} to find out the index, and then provide this index to
`gl.vertexAttribPointer()`.
If you are using WebGL 2, you can specify the index yourself in the vertex shader code
and override the default used by the graphics card, e.g.
`layout(location = 3) in vec4 position;` would set the
`"position"` attribute to index 3.
### Integer attributes
While the `ArrayBuffer` can be filled with both integers and floats, the
attributes will always be converted to a float when they are sent to the vertex shader.
If you need to use integers in your vertex shader code, you can either cast the float
back to an integer in the vertex shader (e.g. `(int) floatNumber`), or use
{{domxref("WebGL2RenderingContext.vertexAttribIPointer()",
"gl.vertexAttribIPointer()")}} from WebGL2.
### Default attribute values
The vertex shader code may include a number of attributes, but we don't need to specify
the values for each attribute. Instead, we can supply a default value that will be
identical for all vertices. We can call
{{domxref("WebGLRenderingContext.disableVertexAttribArray()", "gl.disableVertexAttribArray()")}}
to tell WebGL to use the default value, while calling
{{domxref("WebGLRenderingContext.enableVertexAttribArray()",
"gl.enableVertexAttribArray()")}} will read the values from the array buffer as
specified with `gl.vertexAttribPointer()`.
Similarly, if our vertex shader expects e.g. a 4-component attribute with
`vec4` but in our `gl.vertexAttribPointer()` call we set the
`size` to `2`, then WebGL will set the first two components based
on the array buffer, while the third and fourth components are taken from the default
value.
The default value is `vec4(0.0, 0.0, 0.0, 1.0)` by default but we can
specify a different default value with
{{domxref("WebGLRenderingContext.vertexAttrib()", "gl.vertexAttrib[1234]f[v]()")}}.
For example, your vertex shader may be using a position and a color attribute. Most
meshes have the color specified at a per-vertex level, but some meshes are of a uniform
shade. For those meshes, it is not necessary to place the same color for each vertex
into the array buffer, so you use `gl.vertexAttrib4fv()` to set a constant
color.
### Querying current settings
You can call {{domxref("WebGLRenderingContext.getVertexAttrib()",
"gl.getVertexAttrib()")}} and {{domxref("WebGLRenderingContext.getVertexAttribOffset()",
"gl.getVertexAttribOffset()")}} to get the current parameters for an attribute, e.g. the
data type or whether the attribute should be normalized. Keep in mind that these WebGL
functions have a slow performance and it is better to store the state inside your
JavaScript application. However, these functions are great for debugging a WebGL context
without touching the application code.
## Examples
This example shows how to send your vertex attributes to the shader program. We use an
imaginary data structure where the attributes of each vertex are stored interleaved with
a length of 20 bytes per vertex:
1. **position:** We need to store the X, Y and Z coordinates. For highest
precision, we use 32-bit floats; in total this uses 12 bytes.
2. **normal vector:** We need to store the X, Y and Z components of the
normal vector, but since precision is not that important, we use 8-bit signed
integers. For better performance, we align the data to 32 bits by also storing a
fourth zero-valued component, bringing the total size to 4 bytes. Also, we tell WebGL
to normalize the values because our normals are always in range \[-1, 1].
3. **texture coordinate:** We need to store the U and V coordinates; for
this 16-bit unsigned integers offer enough precision, the total size is 4 bytes. We
also tell WebGL to normalize the values to \[0, 1].
For example, the following vertex:
```json
{
"position": [1.0, 2.0, 1.5],
"normal": [1.0, 0.0, 0.0],
"texCoord": [0.5, 0.25]
}
```
Will be stored in the array buffer as follows:
![WebGL array buffer contents](webgl-array-buffer.svg)
### Creating the array buffer
First, we dynamically create the array buffer from JSON data using a
{{jsxref("DataView")}}. Note the use of `true` because WebGL expects our
data to be in little-endian.
```js
// Load geometry with fetch() and Response.json()
const response = await fetch("assets/geometry.json");
const vertices = await response.json();
// Create array buffer
const buffer = new ArrayBuffer(20 * vertices.length);
// Fill array buffer
const dv = new DataView(buffer);
vertices.forEach((vertex, i) => {
dv.setFloat32(20 * i, vertex.position[0], true);
dv.setFloat32(20 * i + 4, vertex.position[1], true);
dv.setFloat32(20 * i + 8, vertex.position[2], true);
dv.setInt8(20 * i + 12, vertex.normal[0] * 0x7f);
dv.setInt8(20 * i + 13, vertex.normal[1] * 0x7f);
dv.setInt8(20 * i + 14, vertex.normal[2] * 0x7f);
dv.setInt8(20 * i + 15, 0);
dv.setUint16(20 * i + 16, vertex.texCoord[0] * 0xffff, true);
dv.setUint16(20 * i + 18, vertex.texCoord[1] * 0xffff, true);
});
```
For higher performance, we could also do the previous JSON to ArrayBuffer conversion on
the server-side, e.g. with Node.js. Then we could load the binary file and interpret it
as an array buffer:
```js
const response = await fetch("assets/geometry.bin");
const buffer = await response.arrayBuffer();
```
### Consume array buffer with WebGL
First, we create a new Vertex Buffer Object (VBO) and supply it with our array buffer:
```js
//Bind array buffer to a Vertex Buffer Object
const vbo = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.bufferData(gl.ARRAY_BUFFER, buffer, gl.STATIC_DRAW);
```
Then, we specify the memory layout of the array buffer, either by setting the index
ourselves:
```js
//Describe the layout of the buffer:
//1. position, not normalized
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 20, 0);
gl.enableVertexAttribArray(0);
//2. normal vector, normalized to [-1, 1]
gl.vertexAttribPointer(1, 4, gl.BYTE, true, 20, 12);
gl.enableVertexAttribArray(1);
//3. texture coordinates, normalized to [0, 1]
gl.vertexAttribPointer(2, 2, gl.UNSIGNED_SHORT, true, 20, 16);
gl.enableVertexAttribArray(2);
//Set the attributes in the vertex shader to the same indices
gl.bindAttribLocation(shaderProgram, 0, "position");
gl.bindAttribLocation(shaderProgram, 1, "normal");
gl.bindAttribLocation(shaderProgram, 2, "texUV");
//Since the attribute indices have changed, we must re-link the shader
//Note that this will reset all uniforms that were previously set.
gl.linkProgram(shaderProgram);
```
Or we can use the index provided by the graphics card instead of setting the index
ourselves; this avoids the re-linking of the shader program.
```js
const locPosition = gl.getAttribLocation(shaderProgram, "position");
gl.vertexAttribPointer(locPosition, 3, gl.FLOAT, false, 20, 0);
gl.enableVertexAttribArray(locPosition);
const locNormal = gl.getAttribLocation(shaderProgram, "normal");
gl.vertexAttribPointer(locNormal, 4, gl.BYTE, true, 20, 12);
gl.enableVertexAttribArray(locNormal);
const locTexUV = gl.getAttribLocation(shaderProgram, "texUV");
gl.vertexAttribPointer(locTexUV, 2, gl.UNSIGNED_SHORT, true, 20, 16);
gl.enableVertexAttribArray(locTexUV);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Vertex Specification](https://www.khronos.org/opengl/wiki/Vertex_Specification) on the OpenGL wiki
- {{domxref("WebGL2RenderingContext.vertexAttribIPointer()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/vertexattribpointer/webgl-array-buffer.svg | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="461px" height="41px" viewBox="-0.5 -0.5 461 41"><defs/><g><rect x="80" y="0" width="80" height="40" fill="#ddddff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 20px; margin-left: 81px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><font style="font-size: 12px" face="Helvetica"><b><font style="font-size: 12px">00 00 00 40</font></b></font></div></div></div></foreignObject><text x="120" y="24" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">00 00 00 40</text></switch></g><rect x="160" y="0" width="80" height="40" fill="#ddddff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 20px; margin-left: 161px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><font style="font-size: 12px" face="Helvetica"><b><font style="font-size: 12px">00 00 0C 3F</font></b></font></div></div></div></foreignObject><text x="200" y="24" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">00 00 0C 3F</text></switch></g><rect x="270" y="0" width="30" height="40" fill="#ddffdd" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 28px; height: 1px; padding-top: 20px; margin-left: 271px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><font style="font-size: 12px" face="Helvetica"><b><font style="font-size: 12px">00</font></b></font></div></div></div></foreignObject><text x="285" y="24" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">00</text></switch></g><rect x="300" y="0" width="30" height="40" fill="#ddffdd" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 28px; height: 1px; padding-top: 20px; margin-left: 301px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><font style="font-size: 12px" face="Helvetica"><b><font style="font-size: 12px">00</font></b></font></div></div></div></foreignObject><text x="315" y="24" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">00</text></switch></g><rect x="360" y="0" width="50" height="40" fill="#ffdddd" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 48px; height: 1px; padding-top: 20px; margin-left: 361px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><font style="font-size: 12px" face="Helvetica"><b><font style="font-size: 12px">7F FF</font></b></font></div></div></div></foreignObject><text x="385" y="24" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">7F FF</text></switch></g><rect x="330" y="0" width="30" height="40" fill="#ddffdd" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 28px; height: 1px; padding-top: 20px; margin-left: 331px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><font style="font-size: 12px" face="Helvetica"><b><font style="font-size: 12px">00</font></b></font></div></div></div></foreignObject><text x="345" y="24" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">00</text></switch></g><rect x="410" y="0" width="50" height="40" fill="#ffdddd" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 48px; height: 1px; padding-top: 20px; margin-left: 411px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><font style="font-size: 12px" face="Helvetica"><b><font style="font-size: 12px">3F FF</font></b></font></div></div></div></foreignObject><text x="435" y="24" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">3F FF</text></switch></g><rect x="240" y="0" width="30" height="40" fill="#ddffdd" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 28px; height: 1px; padding-top: 20px; margin-left: 241px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><font style="font-size: 12px" face="Helvetica"><b><font style="font-size: 12px">7F</font></b></font></div></div></div></foreignObject><text x="255" y="24" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">7F</text></switch></g><rect x="0" y="0" width="80" height="40" fill="#ddddff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 20px; margin-left: 1px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; "><font style="font-size: 12px" face="Helvetica"><b><font style="font-size: 12px">00 00 80 3F</font></b></font></div></div></div></foreignObject><text x="40" y="24" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">00 00 80 3F</text></switch></g></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://www.diagrams.net/doc/faq/svg-export-text-problems" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Viewer does not support full SVG 1.1</text></a></switch></svg> | 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/stencilop/index.md | ---
title: "WebGLRenderingContext: stencilOp() method"
short-title: stencilOp()
slug: Web/API/WebGLRenderingContext/stencilOp
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.stencilOp
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.stencilOp()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) sets both the front and back-facing
stencil test actions.
## Syntax
```js-nolint
stencilOp(fail, zfail, zpass)
```
### Parameters
All three parameters accept all constants listed below.
- `fail`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the function to use when the stencil test fails.
The default value is `gl.KEEP`.
- `zfail`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the function to use when the stencil test passes,
but the depth test fails. The default value is `gl.KEEP`.
- `zpass`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the function to use when both the stencil test
and the depth test pass, or when the stencil test passes and there is no depth buffer
or depth testing is disabled. The default value is `gl.KEEP`.
### Return value
None ({{jsxref("undefined")}}).
## Constants
- `gl.KEEP`
- : Keeps the current value.
- `gl.ZERO`
- : Sets the stencil buffer value to 0.
- `gl.REPLACE`
- : Sets the stencil buffer value to the reference value as specified by
{{domxref("WebGLRenderingContext.stencilFunc()")}}.
- `gl.INCR`
- : Increments the current stencil buffer value. Clamps to the maximum representable
unsigned value.
- `gl.INCR_WRAP`
- : Increments the current stencil buffer value. Wraps stencil buffer value to zero when
incrementing the maximum representable unsigned value.
- `gl.DECR`
- : Decrements the current stencil buffer value. Clamps to 0.
- `gl.DECR_WRAP`
- : Decrements the current stencil buffer value. Wraps stencil buffer value to the
maximum representable unsigned value when decrementing a stencil buffer value of 0.
- `gl.INVERT`
- : Inverts the current stencil buffer value bitwise.
## Examples
The stencil testing is disabled by default. To enable or disable stencil testing, use
the {{domxref("WebGLRenderingContext.enable", "enable()")}} and
{{domxref("WebGLRenderingContext.disable", "disable()")}} methods with the argument
`gl.STENCIL_TEST`.
```js
gl.enable(gl.STENCIL_TEST);
gl.stencilOp(gl.INCR, gl.DECR, gl.INVERT);
```
To get the current information about stencil and depth pass or fail, query the
following constants with {{domxref("WebGLRenderingContext.getParameter",
"getParameter()")}}.
```js
gl.getParameter(gl.STENCIL_FAIL);
gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS);
gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL);
gl.getParameter(gl.STENCIL_BACK_FAIL);
gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_PASS);
gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_FAIL);
gl.getParameter(gl.STENCIL_BITS);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.stencilOpSeparate()")}}
- {{domxref("WebGLRenderingContext.stencilFunc()")}}
- {{domxref("WebGLRenderingContext.stencilFuncSeparate()")}}
- {{domxref("WebGLRenderingContext.stencilMask()")}}
- {{domxref("WebGLRenderingContext.stencilMaskSeparate()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/createshader/index.md | ---
title: "WebGLRenderingContext: createShader() method"
short-title: createShader()
slug: Web/API/WebGLRenderingContext/createShader
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.createShader
---
{{APIRef("WebGL")}}
The {{domxref("WebGLRenderingContext")}}
method **`createShader()`** of the [WebGL API](/en-US/docs/Web/API/WebGL_API) creates a
{{domxref("WebGLShader")}} that can then be configured further using
{{domxref("WebGLRenderingContext.shaderSource()")}} and
{{domxref("WebGLRenderingContext.compileShader()")}}.
## Syntax
```js-nolint
createShader(type)
```
### Parameters
- `type`
- : Either `gl.VERTEX_SHADER` or `gl.FRAGMENT_SHADER`
### Return value
A new ({{domxref("WebGLShader")}}).
## Examples
See {{domxref("WebGLShader")}} for usage and examples.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLProgram")}}
- {{domxref("WebGLShader")}}
- {{domxref("WebGLRenderingContext.attachShader()")}}
- {{domxref("WebGLRenderingContext.bindAttribLocation()")}}
- {{domxref("WebGLRenderingContext.compileShader()")}}
- {{domxref("WebGLRenderingContext.createProgram()")}}
- {{domxref("WebGLRenderingContext.createShader()")}}
- {{domxref("WebGLRenderingContext.deleteProgram()")}}
- {{domxref("WebGLRenderingContext.deleteShader()")}}
- {{domxref("WebGLRenderingContext.detachShader()")}}
- {{domxref("WebGLRenderingContext.getAttachedShaders()")}}
- {{domxref("WebGLRenderingContext.getProgramParameter()")}}
- {{domxref("WebGLRenderingContext.getProgramInfoLog()")}}
- {{domxref("WebGLRenderingContext.getShaderParameter()")}}
- {{domxref("WebGLRenderingContext.getShaderPrecisionFormat()")}}
- {{domxref("WebGLRenderingContext.getShaderInfoLog()")}}
- {{domxref("WebGLRenderingContext.getShaderSource()")}}
- {{domxref("WebGLRenderingContext.isProgram()")}}
- {{domxref("WebGLRenderingContext.isShader()")}}
- {{domxref("WebGLRenderingContext.linkProgram()")}}
- {{domxref("WebGLRenderingContext.shaderSource()")}}
- {{domxref("WebGLRenderingContext.useProgram()")}}
- {{domxref("WebGLRenderingContext.validateProgram()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/blendfuncseparate/index.md | ---
title: "WebGLRenderingContext: blendFuncSeparate() method"
short-title: blendFuncSeparate()
slug: Web/API/WebGLRenderingContext/blendFuncSeparate
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.blendFuncSeparate
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.blendFuncSeparate()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) defines which function is used
for blending pixel arithmetic for RGB and alpha components separately.
## Syntax
```js-nolint
blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha)
```
### Parameters
- `srcRGB`
- : A {{domxref("WebGL_API.Types")}} specifying a multiplier for the red, green and blue (RGB)
source blending factors. The default value is `gl.ONE`. For possible
values, see below.
- `dstRGB`
- : A {{domxref("WebGL_API.Types")}} specifying a multiplier for the red, green and blue (RGB)
destination blending factors. The default value is `gl.ZERO`. For possible
values, see below.
- `srcAlpha`
- : A {{domxref("WebGL_API.Types")}} specifying a multiplier for the alpha source blending
factor. The default value is `gl.ONE`. For possible values, see below.
- `dstAlpha`
- : A {{domxref("WebGL_API.Types")}} specifying a multiplier for the alpha destination blending
factor. The default value is `gl.ZERO`. For possible values, see below.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
- If _srcRGB_, _dstRGB_, _srcAlpha_, or _dstAlpha_ is not
one of the listed possible values, a `gl.INVALID_ENUM` error is thrown.
- If a constant color and a constant alpha value are used together as source
(`srcRGB`) and destination (`dstRGB`) factors, a
`gl.INVALID_ENUM` error is thrown.
## Constants
The following constants can be used for _srcRGB_, _dstRGB_,
_srcAlpha_, and _dstAlpha_
The formulas for the blending factors can be described like this (all RGBA values are
between 0 and 1):
- color(RGB) = (sourceColor \* _srcRGB_) + (destinationColor \* _dstRGB_)
- color(A) = (sourceAlpha \* _srcAlpha_) + (destinationAlpha \*
_dstAlpha_)
In the following table, R<sub>S</sub>, G<sub>S</sub>, B<sub>S</sub>, A<sub>S</sub> represent respectively
the _red_, _green_, _blue_ and _alpha_ component of the source, while
R<sub>D</sub>, G<sub>D</sub>, B<sub>D</sub>, A<sub>D</sub> represent respectively
the _red_, _green_, _blue_ and _alpha_ component of the destination.
Similarly, R<sub>C</sub>, G<sub>C</sub>, B<sub>C</sub>, A<sub>C</sub> represent respectively
the _red_, _green_, _blue_ and _alpha_ component of a constant color.
They are all values between 0 and 1, included.
<table class="no-markdown">
<thead>
<tr>
<th scope="col">Constant</th>
<th scope="col">RGB factor</th>
<th scope="col">Alpha factor</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>gl.ZERO</code></td>
<td>0,0,0</td>
<td>0</td>
<td>Multiplies all colors by 0.</td>
</tr>
<tr>
<td><code>gl.ONE</code></td>
<td>1,1,1,1</td>
<td>1</td>
<td>Multiplies all colors by 1.</td>
</tr>
<tr>
<td><code>gl.SRC_COLOR</code></td>
<td>R<sub>S</sub>, G<sub>S</sub>, B<sub>S</sub></td>
<td>A<sub>S</sub></td>
<td>Multiplies all colors by the source colors.</td>
</tr>
<tr>
<td><code>gl.ONE_MINUS_SRC_COLOR</code></td>
<td>1-R<sub>S</sub>, 1-G<sub>S</sub>, 1-B<sub>S</sub></td>
<td>1-A<sub>S</sub></td>
<td>Multiplies all colors by 1 minus each source color.</td>
</tr>
<tr>
<td><code>gl.DST_COLOR</code></td>
<td>R<sub>D</sub>, G<sub>D</sub>, B<sub>D</sub></td>
<td>A<sub>D</sub></td>
<td>Multiplies all colors by the destination color.</td>
</tr>
<tr>
<td><code>gl.ONE_MINUS_DST_COLOR</code></td>
<td>1-R<sub>D</sub>, 1-G<sub>D</sub>, 1-B<sub>D</sub></td>
<td>1-A<sub>D</sub></td>
<td>Multiplies all colors by 1 minus each destination color.</td>
</tr>
<tr>
<td><code>gl.SRC_ALPHA</code></td>
<td>A<sub>S</sub>, A<sub>S</sub>, A<sub>S</sub></td>
<td>A<sub>S</sub></td>
<td>Multiplies all colors by the source alpha color.</td>
</tr>
<tr>
<td><code>gl.ONE_MINUS_SRC_ALPHA</code></td>
<td>1-A<sub>S</sub>, 1-A<sub>S</sub>, 1-A<sub>S</sub></td>
<td>1-A<sub>S</sub></td>
<td>Multiplies all colors by 1 minus the source alpha color.</td>
</tr>
<tr>
<td><code>gl.DST_ALPHA</code></td>
<td>A<sub>D</sub>, A<sub>D</sub>, A<sub>D</sub></td>
<td>A<sub>D</sub></td>
<td>Multiplies all colors by the destination alpha color.</td>
</tr>
<tr>
<td><code>gl.ONE_MINUS_DST_ALPHA</code></td>
<td>1-A<sub>D</sub>, 1-A<sub>D</sub>, 1-A<sub>D</sub></td>
<td>1-A<sub>D</sub></td>
<td>Multiplies all colors by 1 minus the destination alpha color.</td>
</tr>
<tr>
<td><code>gl.CONSTANT_COLOR</code></td>
<td>R<sub>C</sub>, G<sub>C</sub>, B<sub>C</sub></td>
<td>A<sub>C</sub></td>
<td>Multiplies all colors by a constant color.</td>
</tr>
<tr>
<td><code>gl.ONE_MINUS_CONSTANT_COLOR</code></td>
<td>1-R<sub>C</sub>, 1-G<sub>C</sub>, 1-B<sub>C</sub></td>
<td>1-A<sub>C</sub></td>
<td>Multiplies all colors by 1 minus a constant color.</td>
</tr>
<tr>
<td><code>gl.CONSTANT_ALPHA</code></td>
<td>A<sub>C</sub>, A<sub>C</sub>, A<sub>C</sub></td>
<td>A<sub>C</sub></td>
<td>Multiplies all colors by a constant alpha value.</td>
</tr>
<tr>
<td><code>gl.ONE_MINUS_CONSTANT_ALPHA</code></td>
<td>1-A<sub>C</sub>, 1-A<sub>C</sub>, 1-A<sub>C</sub></td>
<td>1-A<sub>C</sub></td>
<td>Multiplies all colors by 1 minus a constant alpha value.</td>
</tr>
<tr>
<td><code>gl.SRC_ALPHA_SATURATE</code></td>
<td>
min(A<sub>S</sub>, 1 - A<sub>D</sub>), min(A<sub>S</sub>, 1 -
A<sub>D</sub>), min(A<sub>S</sub>, 1 - A<sub>D</sub>)
</td>
<td>1</td>
<td>
Multiplies the RGB colors by the smaller of either the source alpha
color or the value of 1 minus the destination alpha color. The alpha
value is multiplied by 1.
</td>
</tr>
</tbody>
</table>
## Examples
To use the blend function, you first have to activate blending with
{{domxref("WebGLRenderingContext.enable()")}} with the argument `gl.BLEND`.
```js
gl.enable(gl.BLEND);
gl.blendFuncSeparate(gl.SRC_COLOR, gl.DST_COLOR, gl.ONE, gl.ZERO);
```
To get the current blend function, query the `BLEND_SRC_RGB`,
`BLEND_SRC_ALPHA`, `BLEND_DST_RGB`, and
`BLEND_DST_ALPHA` constants which return one of the blend function constants.
```js
gl.enable(gl.BLEND);
gl.blendFuncSeparate(gl.SRC_COLOR, gl.DST_COLOR, gl.ONE, gl.ZERO);
gl.getParameter(gl.BLEND_SRC_RGB) === gl.SRC_COLOR;
// true
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.blendColor()")}}
- {{domxref("WebGLRenderingContext.blendEquation()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getshadersource/index.md | ---
title: "WebGLRenderingContext: getShaderSource() method"
short-title: getShaderSource()
slug: Web/API/WebGLRenderingContext/getShaderSource
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getShaderSource
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getShaderSource()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) returns the source code of a
{{domxref("WebGLShader")}} as a string.
## Syntax
```js-nolint
getShaderSource(shader)
```
### Parameters
- `shader`
- : A {{domxref("WebGLShader")}} object to get the source code from.
### Return value
A string containing the source code of the shader.
## Examples
```js
const shader = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(shader, originalSource);
const source = gl.getShaderSource(shader);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createShader()")}}
- {{domxref("WebGLRenderingContext.isShader()")}}
- {{domxref("WebGLRenderingContext.deleteShader()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/drawingbufferheight/index.md | ---
title: "WebGLRenderingContext: drawingBufferHeight property"
short-title: drawingBufferHeight
slug: Web/API/WebGLRenderingContext/drawingBufferHeight
page-type: web-api-instance-property
browser-compat: api.WebGLRenderingContext.drawingBufferHeight
---
{{APIRef("WebGL")}}
The read-only **`WebGLRenderingContext.drawingBufferHeight`**
property represents the actual height of the current drawing buffer. It should match the
`height` attribute of the {{HTMLElement("canvas")}} element associated with
this context, but might differ if the implementation is not able to provide the
requested height.
## Value
A number.
## Examples
Given this {{HTMLElement("canvas")}} element:
```html
<canvas id="canvas"></canvas>
```
You can get the height of the drawing buffer with the following lines:
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
gl.drawingBufferHeight; // 150
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.drawingBufferWidth")}}
- {{domxref("WebGLRenderingContext.viewport()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/disable/index.md | ---
title: "WebGLRenderingContext: disable() method"
short-title: disable()
slug: Web/API/WebGLRenderingContext/disable
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.disable
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.disable()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) disables specific WebGL
capabilities for this context.
## Syntax
```js-nolint
disable(capability)
```
### Parameters
- `capability`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying which WebGL capability to disable. Possible
values:
| Constant | Description |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gl.BLEND` | Deactivates blending of the computed fragment color values. See {{domxref("WebGLRenderingContext.blendFunc()")}}. |
| `gl.CULL_FACE` | Deactivates culling of polygons. See {{domxref("WebGLRenderingContext.cullFace()")}}. |
| `gl.DEPTH_TEST` | Deactivates depth comparisons and updates to the depth buffer. See {{domxref("WebGLRenderingContext.depthFunc()")}}. |
| `gl.DITHER` | Deactivates dithering of color components before they get written to the color buffer. |
| `gl.POLYGON_OFFSET_FILL` | Deactivates adding an offset to depth values of polygon's fragments. See {{domxref("WebGLRenderingContext.polygonOffset()")}}. |
| `gl.SAMPLE_ALPHA_TO_COVERAGE` | Deactivates the computation of a temporary coverage value determined by the alpha value. |
| `gl.SAMPLE_COVERAGE` | Deactivates ANDing the fragment's coverage with the temporary coverage value. See {{domxref("WebGLRenderingContext.sampleCoverage()")}}. |
| `gl.SCISSOR_TEST` | Deactivates the scissor test that discards fragments that are outside of the scissor rectangle. See {{domxref("WebGLRenderingContext.scissor()")}}. |
| `gl.STENCIL_TEST` | Deactivates stencil testing and updates to the stencil buffer. See {{domxref("WebGLRenderingContext.stencilFunc()")}}. |
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the
following values are available additionally:
| Constant | Description |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gl.RASTERIZER_DISCARD` | Deactivates that primitives are discarded immediately before the rasterization stage, but after the optional transform feedback stage. `gl.clear()` commands are ignored. |
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.disable(gl.DITHER);
```
To check if a capability is disabled, use the
{{domxref("WebGLRenderingContext.isEnabled()")}} method:
```js
gl.isEnabled(gl.DITHER);
// false
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.enable()")}}
- {{domxref("WebGLRenderingContext.isEnabled()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/createprogram/index.md | ---
title: "WebGLRenderingContext: createProgram() method"
short-title: createProgram()
slug: Web/API/WebGLRenderingContext/createProgram
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.createProgram
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.createProgram()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) creates and initializes a
{{domxref("WebGLProgram")}} object.
## Syntax
```js-nolint
createProgram()
```
### Parameters
None.
### Return value
A {{domxref("WebGLProgram")}} object that is a combination of two compiled
{{domxref("WebGLShader")}}s consisting of a vertex shader and a fragment shader (both
written in GLSL). These are then linked into a usable program.
## Examples
### Creating a WebGL program
```js
const program = gl.createProgram();
// Attach pre-existing shaders
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
const info = gl.getProgramInfoLog(program);
throw `Could not compile WebGL program. \n\n${info}`;
}
```
See {{domxref("WebGLShader")}} for information on creating the
`vertexShader` and `fragmentShader` in the above example.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.deleteProgram()")}}
- {{domxref("WebGLRenderingContext.isProgram()")}}
- {{domxref("WebGLRenderingContext.linkProgram()")}}
- {{domxref("WebGLRenderingContext.useProgram()")}}
- {{domxref("WebGLRenderingContext.validateProgram()")}}
- {{domxref("WebGLRenderingContext.getProgramParameter()")}}
- {{domxref("WebGLRenderingContext.getProgramInfoLog()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/bindbuffer/index.md | ---
title: "WebGLRenderingContext: bindBuffer() method"
short-title: bindBuffer()
slug: Web/API/WebGLRenderingContext/bindBuffer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.bindBuffer
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.bindBuffer()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) binds a given
{{domxref("WebGLBuffer")}} to a target.
## Syntax
```js-nolint
bindBuffer(target, buffer)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values:
- `gl.ARRAY_BUFFER`
- : Buffer containing vertex attributes, such as
vertex coordinates, texture coordinate data, or vertex color data.
- `gl.ELEMENT_ARRAY_BUFFER`
- : Buffer used for element indices.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the following values are available additionally:
- `gl.COPY_READ_BUFFER`
- : Buffer for copying from one buffer object to another.
- `gl.COPY_WRITE_BUFFER`
- : Buffer for copying from one buffer object to another.
- `gl.TRANSFORM_FEEDBACK_BUFFER`
- : Buffer for transform feedback operations.
- `gl.UNIFORM_BUFFER`
- : Buffer used for storing uniform blocks.
- `gl.PIXEL_PACK_BUFFER`
- : Buffer used for pixel transfer operations.
- `gl.PIXEL_UNPACK_BUFFER`
- : Buffer used for pixel transfer operations.
- `buffer`
- : A {{domxref("WebGLBuffer")}} to bind.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
Only one target can be bound to a given {{domxref("WebGLBuffer")}}. An attempt to bind
the buffer to another target will throw an `INVALID_OPERATION` error and the
current buffer binding will remain the same.
A {{domxref("WebGLBuffer")}} which has been marked for deletion with
{{domxref("WebGLRenderingContext.deleteBuffer()", "deleteBuffer")}} cannot be
(re-)bound. An attempt to do so will generate an `INVALID_OPERATION` error,
and the current binding will remain untouched.
## Examples
### Binding a buffer to a target
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
```
### Getting current bindings
To check the current buffer bindings, query the `ARRAY_BUFFER_BINDING`
and `ELEMENT_ARRAY_BUFFER_BINDING` constants.
```js
gl.getParameter(gl.ARRAY_BUFFER_BINDING);
gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createBuffer()")}}
- {{domxref("WebGLRenderingContext.deleteBuffer()")}}
- {{domxref("WebGLRenderingContext.isBuffer()")}}
- Other buffers: {{domxref("WebGLFramebuffer")}}, {{domxref("WebGLRenderbuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/drawarrays/index.md | ---
title: "WebGLRenderingContext: drawArrays() method"
short-title: drawArrays()
slug: Web/API/WebGLRenderingContext/drawArrays
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.drawArrays
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.drawArrays()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) renders primitives from array data.
## Syntax
```js-nolint
drawArrays(mode, first, count)
```
### Parameters
- `mode`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the type primitive to render. Possible values
are:
- `gl.POINTS`: Draws a single dot.
- `gl.LINE_STRIP`: Draws a straight line to the next vertex.
- `gl.LINE_LOOP`: Draws a straight line to the next vertex, and
connects the last vertex back to the first.
- `gl.LINES`: Draws a line between a pair of vertices.
- [`gl.TRIANGLE_STRIP`](https://en.wikipedia.org/wiki/Triangle_strip)
- [`gl.TRIANGLE_FAN`](https://en.wikipedia.org/wiki/Triangle_fan)
- `gl.TRIANGLES`: Draws a triangle for a group of three vertices.
- `first`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the starting index in the array of vector points.
- `count`
- : A {{domxref("WebGL_API/Types", "GLsizei")}} specifying the number of indices to be rendered.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
- If `mode` is not one of the accepted values, a
`gl.INVALID_ENUM` error is thrown.
- If `first` or `count` are negative, a
`gl.INVALID_VALUE` error is thrown.
- if `gl.CURRENT_PROGRAM` is [`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null), a
`gl.INVALID_OPERATION` error is thrown.
## Examples
```js
gl.drawArrays(gl.POINTS, 0, 8);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.drawElements()")}}
- {{domxref("ANGLE_instanced_arrays.drawArraysInstancedANGLE()",
"ext.drawArraysInstancedANGLE()")}}
- {{domxref("ANGLE_instanced_arrays.drawElementsInstancedANGLE()",
"ext.drawElementsInstancedANGLE()")}}
- {{domxref("ANGLE_instanced_arrays.vertexAttribDivisorANGLE()",
"ext.vertexAttribDivisorANGLE()")}}
- {{domxref("WebGL2RenderingContext.drawArraysInstanced()")}}
- {{domxref("WebGL2RenderingContext.drawElementsInstanced()")}}
- {{domxref("WebGL2RenderingContext.vertexAttribDivisor()")}}
- {{domxref("WEBGL_multi_draw.multiDrawArraysWEBGL()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getactiveuniform/index.md | ---
title: "WebGLRenderingContext: getActiveUniform() method"
short-title: getActiveUniform()
slug: Web/API/WebGLRenderingContext/getActiveUniform
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getActiveUniform
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getActiveUniform()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns a
{{domxref("WebGLActiveInfo")}} object containing size, type, and name of a uniform
attribute. It is generally used when querying unknown uniforms either for debugging or
generic library creation.
## Syntax
```js-nolint
getActiveUniform(program, index)
```
### Parameters
- `program`
- : A {{domxref("WebGLProgram")}} specifying the WebGL shader program from which to
obtain the uniform variable's information.
- `index`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the index of the uniform attribute to get. This
value is an index 0 to N - 1 as returned
by {{domxref("WebGLRenderingContext.getProgramParameter",
"gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS)")}}.
### Return value
A {{domxref("WebGLActiveInfo")}} object describing the uniform.
The `type` attribute of the return value will be one of the following:
- `gl.FLOAT`
- `gl.FLOAT_VEC2`
- `gl.FLOAT_VEC3`
- `gl.FLOAT_VEC4`
- `gl.INT`
- `gl.INT_VEC2`
- `gl.INT_VEC3`
- `gl.INT_VEC4`
- `gl.BOOL`
- `gl.BOOL_VEC2`
- `gl.BOOL_VEC3`
- `gl.BOOL_VEC4`
- `gl.FLOAT_MAT2`
- `gl.FLOAT_MAT3`
- `gl.FLOAT_MAT4`
- `gl.SAMPLER_2D`
- `gl.SAMPLER_CUBE`
- When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the
following values are possible additionally:
- `gl.UNSIGNED_INT`
- `gl.UNSIGNED_INT_VEC2`
- `gl.UNSIGNED_INT_VEC3`
- `gl.UNSIGNED_INT_VEC4`
- `gl.FLOAT_MAT2x3`
- `gl.FLOAT_MAT2x4`
- `gl.FLOAT_MAT3x2`
- `gl.FLOAT_MAT3x4`
- `gl.FLOAT_MAT4x2`
- `gl.FLOAT_MAT4x3`
- `gl.SAMPLER_3D`
- `gl.SAMPLER_2D_SHADOW`
- `gl.SAMPLER_2D_ARRAY`
- `gl.SAMPLER_2D_ARRAY_SHADOW`
- `gl.SAMPLER_CUBE_SHADOW`
- `gl.INT_SAMPLER_2D`
- `gl.INT_SAMPLER_3D`
- `gl.INT_SAMPLER_CUBE`
- `gl.INT_SAMPLER_2D_ARRAY`
- `gl.UNSIGNED_INT_SAMPLER_2D`
- `gl.UNSIGNED_INT_SAMPLER_3D`
- `gl.UNSIGNED_INT_SAMPLER_CUBE`
- `gl.UNSIGNED_INT_SAMPLER_2D_ARRAY`
When `gl.linkProgram` is called, WebGL creates a list of active uniforms.
These are possible values of the `name` attribute of return values of
{{domxref("WebGLRenderingContext.getActiveUniform()", "getActiveUniform")}}. WebGL
generates one or more entries in the list depending on the declared type of the uniform
in the shader:
- Single basic type: one entry with the name of the uniform. E.g.
`uniform vec4 a;` will result in `a`.
- Array of basic type: one entry with the name of the uniform suffixed with
`[0]`. E.g. `uniform vec4 b[];` will result in
`b[0]`.
- Struct type: one entry for each member of the struct. E.g.
`uniform struct { float foo; vec4 bar; } c;` will result in
`c.foo` and `c.bar`.
- Arrays of structs or arrays: each entry of the array will generate its own entries.
E.g. `uniform struct { float foo; vec4 bar; } d[2];` will result in:
- `d[0].foo`
- `d[0].bar`
- `d[1].foo`
- `d[1].bar`
- Uniform blocks: one entry for each member. If the uniform block has an instance
name, the block name is prefixed. E.g. `uniform Block { float foo; };` will
result in `foo`, and `uniform Block { float bar; } e;` will
result in `e.bar`.
The `size` attribute of the return value corresponds to the length of the
array for uniforms declared as arrays. Otherwise, it is 1 (this includes interface
blocks instanced with arrays).
### Exceptions
- `gl.INVALID_VALUE` is generated if the program
{{domxref("WebGLProgram")}} is invalid (not linked, deleted, etc.).
- `gl.INVALID_VALUE` is generated if index is not in the range \[0,
`gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS)` - 1].
## Examples
```js
const numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
for (let i = 0; i < numUniforms; ++i) {
const info = gl.getActiveUniform(program, i);
console.log("name:", info.name, "type:", info.type, "size:", info.size);
}
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLActiveInfo")}}
- {{domxref("WebGLRenderingContext.getUniformLocation()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getattriblocation/index.md | ---
title: "WebGLRenderingContext: getAttribLocation() method"
short-title: getAttribLocation()
slug: Web/API/WebGLRenderingContext/getAttribLocation
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getAttribLocation
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getAttribLocation()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns the location of an
attribute variable in a given {{domxref("WebGLProgram")}}.
## Syntax
```js-nolint
getAttribLocation(program, name)
```
### Parameters
- `program`
- : A {{domxref("WebGLProgram")}} containing the attribute variable.
- `name`
- : A string specifying the name of the attribute variable whose
location to get.
### Return value
A {{domxref("WebGL_API/Types", "GLint")}} number indicating the location of the variable name if found.
Returns -1 otherwise.
## Examples
```js
gl.getAttribLocation(program, "vColor");
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getUniformLocation()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/makexrcompatible/index.md | ---
title: "WebGLRenderingContext: makeXRCompatible() method"
short-title: makeXRCompatible()
slug: Web/API/WebGLRenderingContext/makeXRCompatible
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.makeXRCompatible
---
{{APIRef("WebGL")}}
The {{domxref("WebGLRenderingContext")}} method
**`makeXRCompatible()`** ensures that the rendering context
described by the `WebGLRenderingContext` is ready to render the scene for the
immersive [WebXR](/en-US/docs/Web/API/WebXR_Device_API) device on which it
will be displayed. If necessary, the [WebGL](/en-US/docs/Web/API/WebGL_API)
layer may reconfigure the context to be ready to render to a different device than it
originally was.
This is useful if you have an application which can start out being presented on a
standard 2D display but can then be transitioned to a 3D immersion system.
## Syntax
```js-nolint
makeXRCompatible()
```
### Parameters
None.
### Return value
A
[`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
which successfully resolves once the WebGL context is ready to be used for rendering [WebXR](/en-US/docs/Web/API/WebXR_Device_API) content.
### Exceptions
This method doesn't throw traditional exceptions; instead, the promise rejects with one
of the following errors as the value passed into the rejection handler:
- `AbortError` {{domxref("DOMException")}}
- : Returned if switching the context over to the WebXR-compatible context failed.
- `InvalidStateError` {{domxref("DOMException")}}
- : Returned if the WebGL context has been lost or there is no available WebXR device.
## Usage notes
Because `makeXRCompatible()` may involve replacing the underlying WebGL
context with a new one that uses the new rendering hardware, the existing contents of
the context may be lost and, therefore, would need to be re-rendered. This is why the
[`webglcontextlost`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextlost_event)
and
[`webglcontextrestored`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextrestored_event)
events are used: the first gives you the opportunity to discard anything you won't need
anymore, while the second gives you the opportunity to load resources and prepare to
render the scene in its new context.
While this method is available through the {{domxref("WebGLRenderingContext")}}
interface, it's actually defined by the [WebXR Device API](/en-US/docs/Web/API/WebXR_Device_API) rather than by WebGL.
## Examples
This example demonstrates code logic you might find in a game that starts up using
WebGL to display menus and other UI, and uses WebGL to render gameplay, but has a button
on its main menu that offers an option to start the game in WebXR mode.
### HTML
The HTML for the buttons looks like this:
```html
<button class="green button" type="button">Start Game</button>
<button class="blue button use-webxr" type="button">
Start Game (VR mode)
</button>
```
The first button starts the game, continuing to present the game onscreen as usual. The
second button will be used to start the game in `immersive-vr` mode. Note the
inclusion of a `use-webxr` class on the VR mode button. This is important,
which we'll explore shortly.
### JavaScript
The code that handles starting up graphics, switching to VR mode, and so forth looks
like this:
```js
const outputCanvas = document.querySelector(".output-canvas");
const gl = outputCanvas.getContext("webgl");
let xrSession = null;
let usingXR = false;
let currentScene = "scene1";
let glStartButton;
let xrStartButton;
window.addEventListener("load", (event) => {
loadSceneResources(currentScene);
glStartButton.addEventListener("click", handleStartButtonClick);
xrStartButton.addEventListener("click", handleStartButtonClick);
});
outputCanvas.addEventListener("webglcontextlost", (event) => {
/* The context has been lost but can be restored */
event.canceled = true;
});
/* When the GL context is reconnected, reload the resources for the
current scene. */
outputCanvas.addEventListener("webglcontextrestored", (event) => {
loadSceneResources(currentScene);
});
async function onStartedXRSession(xrSession) {
try {
await gl.makeXRCompatible();
} catch (err) {
switch (err) {
case AbortError:
showSimpleMessageBox(
"Unable to transfer the game to your XR headset.",
"Cancel",
);
break;
case InvalidStateError:
showSimpleMessageBox(
"You don't appear to have a compatible XR headset available.",
"Cancel",
);
break;
default:
handleFatalError(err);
break;
}
xrSession.end();
}
}
async function handleStartButtonClick(event) {
if (event.target.classList.contains("use-webxr") && navigator.xr) {
try {
xrSession = await navigator.xr.requestSession("immersive-vr");
usingXR = true;
} catch (err) {
xrSession = NULL;
usingXR = false;
}
}
startGame();
}
function startGame() {
currentScene = "scene1";
loadSceneResources(currentScene);
/* and so on */
}
```
This works by having two buttons, one which starts the game normally and the other
which starts the game in VR mode. These both use the
`handleStartButtonClick()` function as their event handler. The function
determines that the button clicked was the one requesting `immersive-vr` mode
by checking to see if the button has the `use-webxr` class on it. If the
button clicked by the user has that class (and we've confirmed that WebXR is available
by ensuring that the {{domxref("navigator.xr")}} property exists), we use
{{domxref("XRSystem.requestSession", "requestSession()")}} to request a new WebXR
session and set the `usingXR` flag to `true`.
If the other button was clicked, we ensure that `xrSession` is
`NULL` and clear `usingXR` to `false`.
Then the `startGame()` function is called to trigger the beginning of
gameplay.
Handlers are provided for both
[`webglcontextlost`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextlost_event)
and
[`webglcontextrestored`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextrestored_event);
in the first case, we make sure we're aware that the state can be recovered, while in
the latter we actually reload the scene to ensure we have the correct resources for the
current screen or headset configuration.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/colormask/index.md | ---
title: "WebGLRenderingContext: colorMask() method"
short-title: colorMask()
slug: Web/API/WebGLRenderingContext/colorMask
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.colorMask
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.colorMask()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) sets which color components to
enable or to disable when drawing or rendering to a {{domxref("WebGLFramebuffer")}}.
## Syntax
```js-nolint
colorMask(red, green, blue, alpha)
```
### Parameters
- `red`
- : A {{domxref("WebGL_API/Types", "GLboolean")}} specifying whether or not the red color component can be
written into the frame buffer. Default value: `true`.
- `green`
- : A {{domxref("WebGL_API/Types", "GLboolean")}} specifying whether or not the green color component can
be written into the frame buffer. Default value: `true`.
- `blue`
- : A {{domxref("WebGL_API/Types", "GLboolean")}} specifying whether or not the blue color component can be
written into the frame buffer. Default value: `true`.
- `alpha`
- : A {{domxref("WebGL_API/Types", "GLboolean")}} specifying whether or not the alpha (transparency)
component can be written into the frame buffer. Default value: `true`.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.colorMask(true, true, true, false);
```
To get the current color mask, query the `COLOR_WRITEMASK` constant which
returns an {{jsxref("Array")}}.
```js
gl.getParameter(gl.COLOR_WRITEMASK);
// [true, true, true, false]
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.depthMask()")}}
- {{domxref("WebGLRenderingContext.stencilMask()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/depthmask/index.md | ---
title: "WebGLRenderingContext: depthMask() method"
short-title: depthMask()
slug: Web/API/WebGLRenderingContext/depthMask
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.depthMask
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.depthMask()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) sets whether writing into the depth
buffer is enabled or disabled.
## Syntax
```js-nolint
depthMask(flag)
```
### Parameters
- `flag`
- : A {{domxref("WebGL_API/Types", "GLboolean")}} specifying whether or not writing into the depth buffer
is enabled. Default value: `true`, meaning that writing is enabled.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.depthMask(false);
```
To get the current depth mask, query the `DEPTH_WRITEMASK` constant which
returns a boolean value.
```js
gl.getParameter(gl.DEPTH_WRITEMASK);
// false
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.colorMask()")}}
- {{domxref("WebGLRenderingContext.stencilMask()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/iscontextlost/index.md | ---
title: "WebGLRenderingContext: isContextLost() method"
short-title: isContextLost()
slug: Web/API/WebGLRenderingContext/isContextLost
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.isContextLost
---
{{APIRef("WebGL")}}
The
**`WebGLRenderingContext.isContextLost()`** method returns a
boolean value indicating whether or not the WebGL context has been lost and
must be re-established before rendering can resume.
## Syntax
```js-nolint
isContextLost()
```
### Parameters
None.
### Return value
A boolean value which is `true` if the context is lost, or
`false` if not.
## Usage notes
There are several reasons why a WebGL context may be lost, making it necessary to
re-establish the context before resuming rendering. Examples include:
- Two or more pages are using the GPU, but together place too high a demand on the
GPU, so the browser tells the two contexts that they've lost the connection, then
selects one of the two to restore access for.
- The user's computer has multiple graphics processors (such as a laptop with both
mobile and desktop class GPUs, the former used primarily when on battery power), and
the user or system decides to switch GPUs. In this case, all contexts are lost, then
restored after switching GPUs.
- Another page running in the user's browser performs an operation using the GPU that
takes too long, causing the browser to decide to reset the GPU in order to break the
stall. This would cause every WebGL context to be lost throughout the entire browser.
- The user updates their graphics driver on an operating system that allows graphics
drivers to be updated without restarting the system.
## Examples
For example, when checking for program linking success, you could also check if the
context is not lost:
```js
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS) && !gl.isContextLost()) {
const info = gl.getProgramInfoLog(program);
console.log(`Error linking program:\n${info}`);
}
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- The {{domxref("WebGLContextEvent")}} signals changes in the context state.
- [Handling lost context in WebGL](https://www.khronos.org/webgl/wiki/HandlingContextLost): Khronos WebGL wiki
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/enablevertexattribarray/index.md | ---
title: "WebGLRenderingContext: enableVertexAttribArray() method"
short-title: enableVertexAttribArray()
slug: Web/API/WebGLRenderingContext/enableVertexAttribArray
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.enableVertexAttribArray
---
{{APIRef("WebGL")}}
The {{domxref("WebGLRenderingContext")}} method
**`enableVertexAttribArray()`**, part of the [WebGL API](/en-US/docs/Web/API/WebGL_API), turns on the generic vertex
attribute array at the specified index into the list of attribute arrays.
> **Note:** You can disable the attribute array by calling
> {{domxref("WebGLRenderingContext.disableVertexAttribArray", "disableVertexAttribArray()")}}.
In WebGL, values that apply to a specific vertex are stored in [attributes](/en-US/docs/Web/API/WebGL_API/Data#attributes). These are only
available to the JavaScript code and the vertex shader. Attributes are referenced by an
index number into the list of attributes maintained by the GPU. Some vertex attribute
indices may have predefined purposes, depending on the platform and/or the GPU. Others
are assigned by the WebGL layer when you create the attributes.
Either way, since attributes cannot be used unless enabled, and are disabled by
default, you need to call `enableVertexAttribArray()` to enable individual
attributes so that they can be used. Once that's been done, other methods can be used to
access the attribute, including {{domxref("WebGLRenderingContext.vertexAttribPointer",
"vertexAttribPointer()")}}, {{domxref("WebGLRenderingContext.vertexAttrib",
"vertexAttrib*()")}}, and {{domxref("WebGLRenderingContext.getVertexAttrib",
"getVertexAttrib()")}}.
## Syntax
```js-nolint
enableVertexAttribArray(index)
```
### Parameters
- `index`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the index number that uniquely identifies the
vertex attribute to enable. If you know the name of the attribute but not its index,
you can get the index by calling {{domxref("WebGLRenderingContext.getAttribLocation",
"getAttribLocation()")}}.
### Return value
None ({{jsxref("undefined")}}).
### Errors
To check for errors after calling `enableVertexAttribArray()`, call
{{domxref("WebGLRenderingContext.getError", "getError()")}}.
- `WebGLRenderingContext.INVALID_VALUE`
- : The specified `index` is invalid; that is, it's greater than or equal to
the maximum number of entries permitted in the context's vertex attribute list, as
indicated by the value of `WebGLRenderingContext.MAX_VERTEX_ATTRIBS`.
## Examples
This code — a snippet taken from the full example [A basic 2D WebGL animation example](/en-US/docs/Web/API/WebGL_API/Basic_2D_animation_example) — shows the use of `enableVertexArray()` to activate
the attribute that will be used by the WebGL layer to pass individual vertexes from the
vertex buffer into the vertex shader function.
```js
gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
aVertexPosition = gl.getAttribLocation(shaderProgram, "aVertexPosition");
gl.enableVertexAttribArray(aVertexPosition);
gl.vertexAttribPointer(
aVertexPosition,
vertexNumComponents,
gl.FLOAT,
false,
0,
0,
);
gl.drawArrays(gl.TRIANGLES, 0, vertexCount);
```
> **Note:** This code snippet is taken from [the function `animateScene()`](/en-US/docs/Web/API/WebGL_API/Basic_2D_animation_example#drawing_and_animating_the_scene) in "A basic 2D WebGL animation example." See
> that article for the full sample and to see the resulting animation in action.
This code sets the buffer of vertexes that will be used to draw the triangles of the
shape by calling {{domxref("WebGLRenderingContext.bindBuffer", "bindBuffer()")}}. Then
the vertex position attribute's index is obtained from the shader program by calling
{{domxref("WebGLRenderingContext.getAttribLocation", "getAttribLocation()")}}.
With the index of the vertex position attribute now available in
`aVertexPosition`, we call `enableVertexAttribArray()` to enable
the position attribute so it can be used by the shader program (in particular, by the
vertex shader).
Then the vertex buffer is bound to the `aVertexPosition` attribute by
calling {{domxref("WebGLRenderingContext.vertexAttribPointer",
"vertexAttribPointer()")}}. This step is not obvious, since this binding is almost a
side effect. But as a result, accessing `aVertexPosition` now obtains data
from the vertex buffer.
With the association in place between the vertex buffer for our shape and the
`aVertexPosition` attribute used to deliver vertexes one by one into the
vertex shader, we're ready to draw the shape by calling
{{domxref("WebGLRenderingContext.drawArrays", "drawArrays()")}}.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Data in WebGL](/en-US/docs/Web/API/WebGL_API/Data)
- [Adding 2D content to a WebGL context](/en-US/docs/Web/API/WebGL_API/Tutorial/Adding_2D_content_to_a_WebGL_context)
- [A basic 2D WebGL animation sample](/en-US/docs/Web/API/WebGL_API/Basic_2D_animation_example)
- {{domxref("WebGLRenderingContext.disableVertexAttribArray",
"disableVertexAttribArray()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/detachshader/index.md | ---
title: "WebGLRenderingContext: detachShader() method"
short-title: detachShader()
slug: Web/API/WebGLRenderingContext/detachShader
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.detachShader
---
{{APIRef("WebGL")}}
The **WebGLRenderingContext.detachShader()** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) detaches a previously
attached {{domxref("WebGLShader")}} from a {{domxref("WebGLProgram")}}.
## Syntax
```js-nolint
detachShader(program, shader)
```
### Parameters
- `program`
- : A {{domxref("WebGLProgram")}}.
- `shader`
- : A fragment or vertex {{domxref("WebGLShader")}}.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLProgram")}}
- {{domxref("WebGLShader")}}
- {{domxref("WebGLRenderingContext.attachShader()")}}
- {{domxref("WebGLRenderingContext.compileShader()")}}
- {{domxref("WebGLRenderingContext.createProgram()")}}
- {{domxref("WebGLRenderingContext.createShader()")}}
- {{domxref("WebGLRenderingContext.deleteProgram()")}}
- {{domxref("WebGLRenderingContext.deleteShader()")}}
- {{domxref("WebGLRenderingContext.detachShader()")}}
- {{domxref("WebGLRenderingContext.getAttachedShaders()")}}
- {{domxref("WebGLRenderingContext.getProgramParameter()")}}
- {{domxref("WebGLRenderingContext.getProgramInfoLog()")}}
- {{domxref("WebGLRenderingContext.getShaderParameter()")}}
- {{domxref("WebGLRenderingContext.getShaderPrecisionFormat()")}}
- {{domxref("WebGLRenderingContext.getShaderInfoLog()")}}
- {{domxref("WebGLRenderingContext.getShaderSource()")}}
- {{domxref("WebGLRenderingContext.isProgram()")}}
- {{domxref("WebGLRenderingContext.isShader()")}}
- {{domxref("WebGLRenderingContext.linkProgram()")}}
- {{domxref("WebGLRenderingContext.shaderSource()")}}
- {{domxref("WebGLRenderingContext.useProgram()")}}
- {{domxref("WebGLRenderingContext.validateProgram()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/canvas/index.md | ---
title: "WebGLRenderingContext: canvas property"
short-title: canvas
slug: Web/API/WebGLRenderingContext/canvas
page-type: web-api-instance-property
browser-compat: api.WebGLRenderingContext.canvas
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.canvas`** property is a read-only
reference to the {{domxref("HTMLCanvasElement")}} or {{domxref("OffscreenCanvas")}}
object that is associated with the context. It might be [`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null) if it is not
associated with a {{HTMLElement("canvas")}} element or an {{domxref("OffscreenCanvas")}}
object.
## Syntax
```js-nolint
gl.canvas
```
### Return value
Either a {{domxref("HTMLCanvasElement")}} or {{domxref("OffscreenCanvas")}} object or
[`null`](/en-US/docs/Web/JavaScript/Reference/Operators/null).
## Examples
### Canvas element
Given this {{HTMLElement("canvas")}} element:
```html
<canvas id="canvas"></canvas>
```
You can get back a reference to it from the `WebGLRenderingContext` using
the `canvas` property:
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
gl.canvas; // HTMLCanvasElement
```
### Offscreen canvas
Example using the experimental {{domxref("OffscreenCanvas")}} object.
```js
const offscreen = new OffscreenCanvas(256, 256);
const gl = offscreen.getContext("webgl");
gl.canvas; // OffscreenCanvas
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("CanvasRenderingContext2D.canvas")}}
- The {{domxref("OffscreenCanvas")}} interface
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/isframebuffer/index.md | ---
title: "WebGLRenderingContext: isFramebuffer() method"
short-title: isFramebuffer()
slug: Web/API/WebGLRenderingContext/isFramebuffer
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.isFramebuffer
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.isFramebuffer()`** method of the
[WebGL API](/en-US/docs/Web/API/WebGL_API) returns `true` if the
passed {{domxref("WebGLFramebuffer")}} is valid and `false` otherwise.
## Syntax
```js-nolint
isFramebuffer(framebuffer)
```
### Parameters
- `framebuffer`
- : A {{domxref("WebGLFramebuffer")}} to check.
### Return value
A {{domxref("WebGL_API/Types", "GLboolean")}} indicating whether or not the frame buffer is valid.
## Examples
### Checking a frame buffer
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const framebuffer = gl.createFramebuffer();
gl.isFramebuffer(framebuffer);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindFramebuffer()")}}
- {{domxref("WebGLRenderingContext.createFramebuffer()")}}
- {{domxref("WebGLRenderingContext.deleteFramebuffer()")}}
- Other buffers: {{domxref("WebGLBuffer")}}, {{domxref("WebGLRenderbuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/clearstencil/index.md | ---
title: "WebGLRenderingContext: clearStencil() method"
short-title: clearStencil()
slug: Web/API/WebGLRenderingContext/clearStencil
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.clearStencil
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.clearStencil()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specifies the clear value for the
stencil buffer.
This specifies what stencil value to use when calling the
{{domxref("WebGLRenderingContext.clear", "clear()")}} method.
## Syntax
```js-nolint
clearStencil(s)
```
### Parameters
- `s`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the index used when the stencil buffer is cleared.
Default value: 0.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.clearStencil(1);
```
To get the current stencil clear value, query the `STENCIL_CLEAR_VALUE`
constant.
```js
gl.getParameter(gl.STENCIL_CLEAR_VALUE);
// 1
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.clear()")}}
- {{domxref("WebGLRenderingContext.clearColor()")}}
- {{domxref("WebGLRenderingContext.clearDepth()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getbufferparameter/index.md | ---
title: "WebGLRenderingContext: getBufferParameter() method"
short-title: getBufferParameter()
slug: Web/API/WebGLRenderingContext/getBufferParameter
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getBufferParameter
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getBufferParameter()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns information about the
buffer.
## Syntax
```js-nolint
getBufferParameter(target, pname)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the target buffer object. Possible values:
- `gl.ARRAY_BUFFER`
- : Buffer containing vertex attributes, such as
vertex coordinates, texture coordinate data, or vertex color data.
- `gl.ELEMENT_ARRAY_BUFFER`
- : Buffer used for element indices.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.COPY_READ_BUFFER`
- : Buffer for copying from one buffer object to another.
- `gl.COPY_WRITE_BUFFER`
- : Buffer for copying from one buffer object to another.
- `gl.TRANSFORM_FEEDBACK_BUFFER`
- : Buffer for transform feedback operations.
- `gl.UNIFORM_BUFFER`
- : Buffer used for storing uniform blocks.
- `gl.PIXEL_PACK_BUFFER`
- : Buffer used for pixel transfer operations.
- `gl.PIXEL_UNPACK_BUFFER`
- : Buffer used for pixel transfer operations.
- `pname`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying information to query. Possible values:
- `gl.BUFFER_SIZE`
- : Returns a {{domxref("WebGL_API/Types", "GLint")}} indicating the size
of the buffer in bytes.
- `gl.BUFFER_USAGE`
- : Returns a {{domxref("WebGL_API/Types", "GLenum")}} indicating the
usage pattern of the buffer. One of the following:
- `gl.STATIC_DRAW`
- `gl.DYNAMIC_DRAW`
- `gl.STREAM_DRAW`
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.STATIC_READ`
- `gl.DYNAMIC_READ`
- `gl.STREAM_READ`
- `gl.STATIC_COPY`
- `gl.DYNAMIC_COPY`
- `gl.STREAM_COPY`
### Return value
Depends on the requested information (as specified with `pname`). Either a
{{domxref("WebGL_API/Types", "GLint")}} or a {{domxref("WebGL_API/Types", "GLenum")}}.
## Examples
```js
gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindBuffer()")}}
- {{domxref("WebGLRenderingContext.createBuffer()")}}
- {{domxref("WebGLRenderingContext.deleteBuffer()")}}
- {{domxref("WebGLRenderingContext.bufferData()")}}
- Other buffers: {{domxref("WebGLFramebuffer")}}, {{domxref("WebGLRenderbuffer")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getparameter/index.md | ---
title: "WebGLRenderingContext: getParameter() method"
short-title: getParameter()
slug: Web/API/WebGLRenderingContext/getParameter
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getParameter
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getParameter()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns a value for the passed
parameter name.
## Syntax
```js-nolint
getParameter(pname)
```
### Parameters
- `pname`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying which parameter value to return. See below for
possible values.
### Return value
Depends on the parameter.
## Parameter names
### WebGL 1
You can query the following `pname` parameters when using a
{{domxref("WebGLRenderingContext")}}.
<table class="no-markdown">
<thead>
<tr>
<th scope="col">Constant</th>
<th scope="col">Returned type</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>gl.ACTIVE_TEXTURE</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.ALIASED_LINE_WIDTH_RANGE</code></td>
<td>{{jsxref("Float32Array")}} (with 2 elements)</td>
<td></td>
</tr>
<tr>
<td><code>gl.ALIASED_POINT_SIZE_RANGE</code></td>
<td>{{jsxref("Float32Array")}} (with 2 elements)</td>
<td></td>
</tr>
<tr>
<td><code>gl.ALPHA_BITS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.ARRAY_BUFFER_BINDING</code></td>
<td>{{domxref("WebGLBuffer")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.BLEND</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.BLEND_COLOR</code></td>
<td>{{jsxref("Float32Array")}} (with 4 values)</td>
<td></td>
</tr>
<tr>
<td><code>gl.BLEND_DST_ALPHA</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.BLEND_DST_RGB</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.BLEND_EQUATION</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.BLEND_EQUATION_ALPHA</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.BLEND_EQUATION_RGB</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.BLEND_SRC_ALPHA</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.BLEND_SRC_RGB</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.BLUE_BITS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.COLOR_CLEAR_VALUE</code></td>
<td>{{jsxref("Float32Array")}} (with 4 values)</td>
<td></td>
</tr>
<tr>
<td><code>gl.COLOR_WRITEMASK</code></td>
<td>
sequence<{{domxref("WebGL_API/Types", "GLboolean")}}>
(with 4 values)
</td>
<td></td>
</tr>
<tr>
<td><code>gl.COMPRESSED_TEXTURE_FORMATS</code></td>
<td>{{jsxref("Uint32Array")}}</td>
<td>
Returns the compressed texture formats.<br /><br />When using the
{{domxref("WEBGL_compressed_texture_s3tc")}} extension:
<ul>
<li><code>ext.COMPRESSED_RGB_S3TC_DXT1_EXT</code></li>
<li><code>ext.COMPRESSED_RGBA_S3TC_DXT1_EXT</code></li>
<li><code>ext.COMPRESSED_RGBA_S3TC_DXT3_EXT</code></li>
<li><code>ext.COMPRESSED_RGBA_S3TC_DXT5_EXT</code></li>
</ul>
<p>
When using the
{{domxref("WEBGL_compressed_texture_s3tc_srgb")}}
extension:
</p>
<ul>
<li><code>ext.COMPRESSED_SRGB_S3TC_DXT1_EXT</code></li>
<li><code>ext.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT</code></li>
<li><code>ext.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT</code></li>
<li><code>ext.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT</code></li>
</ul>
When using the {{domxref("WEBGL_compressed_texture_etc")}}
extension:
<ul>
<li><code>ext.COMPRESSED_R11_EAC</code></li>
<li><code>ext.COMPRESSED_SIGNED_R11_EAC</code></li>
<li><code>ext.COMPRESSED_RG11_EAC</code></li>
<li><code>ext.COMPRESSED_SIGNED_RG11_EAC</code></li>
<li><code>ext.COMPRESSED_RGB8_ETC2</code></li>
<li><code>ext.COMPRESSED_RGBA8_ETC2_EAC</code></li>
<li><code>ext.COMPRESSED_SRGB8_ETC2</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC</code></li>
<li><code>ext.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2</code></li>
<li><code>ext.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2</code></li>
</ul>
When using the
{{domxref("WEBGL_compressed_texture_pvrtc")}} extension:
<ul>
<li><code>ext.COMPRESSED_RGB_PVRTC_4BPPV1_IMG</code></li>
<li><code>ext.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG</code></li>
<li><code>ext.COMPRESSED_RGB_PVRTC_2BPPV1_IMG</code></li>
<li><code>ext.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG</code></li>
</ul>
When using the
{{domxref("WEBGL_compressed_texture_etc1")}} extension:
<ul>
<li><code>ext.COMPRESSED_RGB_ETC1_WEBGL</code></li>
</ul>
When using the
{{domxref("WEBGL_compressed_texture_astc")}} extension:
<ul>
<li><code>ext.COMPRESSED_RGBA_ASTC_4x4_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR</code></li>
<li><code>ext.COMPRESSED_RGBA_ASTC_5x4_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR</code></li>
<li><code>ext.COMPRESSED_RGBA_ASTC_5x5_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR</code></li>
<li><code>ext.COMPRESSED_RGBA_ASTC_6x5_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR</code></li>
<li><code>ext.COMPRESSED_RGBA_ASTC_6x6_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR</code></li>
<li><code>ext.COMPRESSED_RGBA_ASTC_8x5_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR</code></li>
<li><code>ext.COMPRESSED_RGBA_ASTC_8x6_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR</code></li>
<li><code>ext.COMPRESSED_RGBA_ASTC_8x8_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR</code></li>
<li><code>ext.COMPRESSED_RGBA_ASTC_10x5_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR</code></li>
<li><code>ext.COMPRESSED_RGBA_ASTC_10x6_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR</code></li>
<li><code>ext.COMPRESSED_RGBA_ASTC_10x6_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR</code></li>
<li><code>ext.COMPRESSED_RGBA_ASTC_10x10_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR</code></li>
<li><code>ext.COMPRESSED_RGBA_ASTC_12x10_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR</code></li>
<li><code>ext.COMPRESSED_RGBA_ASTC_12x12_KHR</code></li>
<li><code>ext.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR</code></li>
</ul>
</td>
</tr>
<tr>
<td><code>gl.CULL_FACE</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.CULL_FACE_MODE</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>
<code>gl.FRONT</code>, <code>gl.BACK</code> or
<code>gl.FRONT_AND_BACK</code>. See also
{{domxref("WebGLRenderingContext/cullFace", "cullFace")}}
</td>
</tr>
<tr>
<td><code>gl.CURRENT_PROGRAM</code></td>
<td>{{domxref("WebGLProgram")}} or <code>null</code></td>
<td>
See
{{domxref("WebGLRenderingContext/useProgram", "useProgram")}}.
</td>
</tr>
<tr>
<td><code>gl.DEPTH_BITS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.DEPTH_CLEAR_VALUE</code></td>
<td>{{domxref("WebGL_API/Types", "GLfloat")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.DEPTH_FUNC</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.DEPTH_RANGE</code></td>
<td>{{jsxref("Float32Array")}} (with 2 elements)</td>
<td></td>
</tr>
<tr>
<td><code>gl.DEPTH_TEST</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.DEPTH_WRITEMASK</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.DITHER</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.ELEMENT_ARRAY_BUFFER_BINDING</code></td>
<td>{{domxref("WebGLBuffer")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.FRAMEBUFFER_BINDING</code></td>
<td>{{domxref("WebGLFramebuffer")}} or <code>null</code></td>
<td>
<code>null</code> corresponds to a binding to the default framebuffer.
See also
{{domxref("WebGLRenderingContext/bindFramebuffer", "bindFramebuffer")}}.
</td>
</tr>
<tr>
<td><code>gl.FRONT_FACE</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>
<code>gl.CW</code> or <code>gl.CCW</code>. See also
{{domxref("WebGLRenderingContext/frontFace", "frontFace")}}.
</td>
</tr>
<tr>
<td><code>gl.GENERATE_MIPMAP_HINT</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>
<code>gl.FASTEST</code>, <code>gl.NICEST</code> or
<code>gl.DONT_CARE</code>. See also
{{domxref("WebGLRenderingContext/hint", "hint")}}.
</td>
</tr>
<tr>
<td><code>gl.GREEN_BITS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.IMPLEMENTATION_COLOR_READ_FORMAT</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.IMPLEMENTATION_COLOR_READ_TYPE</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.LINE_WIDTH</code></td>
<td>{{domxref("WebGL_API/Types", "GLfloat")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_CUBE_MAP_TEXTURE_SIZE</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_FRAGMENT_UNIFORM_VECTORS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_RENDERBUFFER_SIZE</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_TEXTURE_IMAGE_UNITS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_TEXTURE_SIZE</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_VARYING_VECTORS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_VERTEX_ATTRIBS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_VERTEX_UNIFORM_VECTORS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_VIEWPORT_DIMS</code></td>
<td>{{jsxref("Int32Array")}} (with 2 elements)</td>
<td></td>
</tr>
<tr>
<td><code>gl.PACK_ALIGNMENT</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.POLYGON_OFFSET_FACTOR</code></td>
<td>{{domxref("WebGL_API/Types", "GLfloat")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.POLYGON_OFFSET_FILL</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.POLYGON_OFFSET_UNITS</code></td>
<td>{{domxref("WebGL_API/Types", "GLfloat")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.RED_BITS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.RENDERBUFFER_BINDING</code></td>
<td>{{domxref("WebGLRenderbuffer")}} or <code>null</code></td>
<td>
See
{{domxref("WebGLRenderingContext/bindRenderbuffer", "bindRenderbuffer")}}.
</td>
</tr>
<tr>
<td><code>gl.RENDERER</code></td>
<td>string</td>
<td></td>
</tr>
<tr>
<td><code>gl.SAMPLE_BUFFERS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.SAMPLE_COVERAGE_INVERT</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.SAMPLE_COVERAGE_VALUE</code></td>
<td>{{domxref("WebGL_API/Types", "GLfloat")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.SAMPLES</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.SCISSOR_BOX</code></td>
<td>{{jsxref("Int32Array")}} (with 4 elements)</td>
<td></td>
</tr>
<tr>
<td><code>gl.SCISSOR_TEST</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.SHADING_LANGUAGE_VERSION</code></td>
<td>string</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_BACK_FAIL</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_BACK_FUNC</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_BACK_PASS_DEPTH_FAIL</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_BACK_PASS_DEPTH_PASS</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_BACK_REF</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_BACK_VALUE_MASK</code></td>
<td>{{domxref("WebGL_API/Types", "GLuint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_BACK_WRITEMASK</code></td>
<td>{{domxref("WebGL_API/Types", "GLuint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_BITS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_CLEAR_VALUE</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_FAIL</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_FUNC</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_PASS_DEPTH_FAIL</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_PASS_DEPTH_PASS</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_REF</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_TEST</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_VALUE_MASK</code></td>
<td>{{domxref("WebGL_API/Types", "GLuint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.STENCIL_WRITEMASK</code></td>
<td>{{domxref("WebGL_API/Types", "GLuint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.SUBPIXEL_BITS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.TEXTURE_BINDING_2D</code></td>
<td>{{domxref("WebGLTexture")}} or <code>null</code></td>
<td></td>
</tr>
<tr>
<td><code>gl.TEXTURE_BINDING_CUBE_MAP</code></td>
<td>{{domxref("WebGLTexture")}} or <code>null</code></td>
<td></td>
</tr>
<tr>
<td><code>gl.UNPACK_ALIGNMENT</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.UNPACK_COLORSPACE_CONVERSION_WEBGL</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.UNPACK_FLIP_Y_WEBGL</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.VENDOR</code></td>
<td>string</td>
<td></td>
</tr>
<tr>
<td><code>gl.VERSION</code></td>
<td>string</td>
<td></td>
</tr>
<tr>
<td><code>gl.VIEWPORT</code></td>
<td>{{jsxref("Int32Array")}} (with 4 elements)</td>
<td></td>
</tr>
</tbody>
</table>
### WebGL 2
You can query the following `pname` parameters when using a
{{domxref("WebGL2RenderingContext")}}.
<table class="no-markdown">
<thead>
<tr>
<th scope="col">Constant</th>
<th scope="col">Returned type</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>gl.COPY_READ_BUFFER_BINDING</code></td>
<td>{{domxref("WebGLBuffer")}} or <code>null</code></td>
<td>
See
{{domxref("WebGLRenderingContext/bindBuffer", "bindBuffer")}}.
</td>
</tr>
<tr>
<td><code>gl.COPY_WRITE_BUFFER_BINDING</code></td>
<td>{{domxref("WebGLBuffer")}} or <code>null</code></td>
<td>
See
{{domxref("WebGLRenderingContext/bindBuffer", "bindBuffer")}}.
</td>
</tr>
<tr>
<td>
<code>gl.DRAW_BUFFER<em>i</em></code>
</td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>
<code>gl.BACK</code>, <code>gl.NONE</code> or
<code>gl.COLOR_ATTACHMENT{0-15}</code>. See also
{{domxref("WebGL2RenderingContext/drawBuffers", "drawBuffers")}}.
</td>
</tr>
<tr>
<td><code>gl.DRAW_FRAMEBUFFER_BINDING</code></td>
<td>{{domxref("WebGLFramebuffer")}} or <code>null</code></td>
<td>
<code>null</code> corresponds to a binding to the default framebuffer.
See also
{{domxref("WebGLRenderingContext/bindFramebuffer", "bindFramebuffer")}}.
</td>
</tr>
<tr>
<td><code>gl.FRAGMENT_SHADER_DERIVATIVE_HINT</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>
<code>gl.FASTEST</code>, <code>gl.NICEST</code> or
<code>gl.DONT_CARE</code>. See also
{{domxref("WebGLRenderingContext/hint", "hint")}}.
</td>
</tr>
<tr>
<td><code>gl.MAX_3D_TEXTURE_SIZE</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_ARRAY_TEXTURE_LAYERS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_CLIENT_WAIT_TIMEOUT_WEBGL</code></td>
<td>{{domxref("WebGL_API/Types", "GLint64")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_COLOR_ATTACHMENTS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint64")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_COMBINED_UNIFORM_BLOCKS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint64")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_DRAW_BUFFERS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_ELEMENT_INDEX</code></td>
<td>{{domxref("WebGL_API/Types", "GLint64")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_ELEMENTS_INDICES</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_ELEMENTS_VERTICES</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_FRAGMENT_INPUT_COMPONENTS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_FRAGMENT_UNIFORM_BLOCKS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_FRAGMENT_UNIFORM_COMPONENTS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_PROGRAM_TEXEL_OFFSET</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_SAMPLES</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_SERVER_WAIT_TIMEOUT</code></td>
<td>{{domxref("WebGL_API/Types", "GLint64")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_TEXTURE_LOD_BIAS</code></td>
<td>{{domxref("WebGL_API/Types", "GLfloat")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_UNIFORM_BLOCK_SIZE</code></td>
<td>{{domxref("WebGL_API/Types", "GLint64")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_UNIFORM_BUFFER_BINDINGS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_VARYING_COMPONENTS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_VERTEX_OUTPUT_COMPONENTS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_VERTEX_UNIFORM_BLOCKS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MAX_VERTEX_UNIFORM_COMPONENTS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.MIN_PROGRAM_TEXEL_OFFSET</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.PACK_ROW_LENGTH</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>
See
{{domxref("WebGLRenderingContext/pixelStorei", "pixelStorei")}}.
</td>
</tr>
<tr>
<td><code>gl.PACK_SKIP_PIXELS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>
See
{{domxref("WebGLRenderingContext/pixelStorei", "pixelStorei")}}.
</td>
</tr>
<tr>
<td><code>gl.PACK_SKIP_ROWS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>
See
{{domxref("WebGLRenderingContext/pixelStorei", "pixelStorei")}}.
</td>
</tr>
<tr>
<td><code>gl.PIXEL_PACK_BUFFER_BINDING</code></td>
<td>{{domxref("WebGLBuffer")}} or <code>null</code></td>
<td>
See
{{domxref("WebGLRenderingContext/bindBuffer", "bindBuffer")}}.
</td>
</tr>
<tr>
<td><code>gl.PIXEL_UNPACK_BUFFER_BINDING</code></td>
<td>{{domxref("WebGLBuffer")}} or <code>null</code></td>
<td>
See
{{domxref("WebGLRenderingContext/bindBuffer", "bindBuffer")}}.
</td>
</tr>
<tr>
<td><code>gl.RASTERIZER_DISCARD</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.READ_BUFFER</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.READ_FRAMEBUFFER_BINDING</code></td>
<td>{{domxref("WebGLFramebuffer")}} or <code>null</code></td>
<td>
<code>null</code> corresponds to a binding to the default framebuffer.
See also
{{domxref("WebGLRenderingContext/bindFramebuffer", "bindFramebuffer")}}.
</td>
</tr>
<tr>
<td><code>gl.SAMPLE_ALPHA_TO_COVERAGE</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.SAMPLE_COVERAGE</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.SAMPLER_BINDING</code></td>
<td>{{domxref("WebGLSampler")}} or <code>null</code></td>
<td>
See
{{domxref("WebGL2RenderingContext/bindSampler", "bindSampler")}}.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_BINDING_2D_ARRAY</code></td>
<td>{{domxref("WebGLTexture")}} or <code>null</code></td>
<td>
See
{{domxref("WebGLRenderingContext/bindTexture", "bindTexture")}}.
</td>
</tr>
<tr>
<td><code>gl.TEXTURE_BINDING_3D</code></td>
<td>{{domxref("WebGLTexture")}} or <code>null</code></td>
<td>
See
{{domxref("WebGLRenderingContext/bindTexture", "bindTexture")}}.
</td>
</tr>
<tr>
<td><code>gl.TRANSFORM_FEEDBACK_ACTIVE</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.TRANSFORM_FEEDBACK_BINDING</code></td>
<td>
{{domxref("WebGLTransformFeedback")}} or <code>null</code>
</td>
<td>
See
{{domxref("WebGL2RenderingContext/bindTransformFeedback",
"bindTransformFeedback")}}.
</td>
</tr>
<tr>
<td><code>gl.TRANSFORM_FEEDBACK_BUFFER_BINDING</code></td>
<td>{{domxref("WebGLBuffer")}} or <code>null</code></td>
<td>
See
{{domxref("WebGLRenderingContext/bindBuffer", "bindBuffer")}}.
</td>
</tr>
<tr>
<td><code>gl.TRANSFORM_FEEDBACK_PAUSED</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td></td>
</tr>
<tr>
<td><code>gl.UNIFORM_BUFFER_BINDING</code></td>
<td>{{domxref("WebGLBuffer")}} or <code>null</code></td>
<td>
See
{{domxref("WebGLRenderingContext/bindBuffer", "bindBuffer")}}.
</td>
</tr>
<tr>
<td><code>gl.UNIFORM_BUFFER_OFFSET_ALIGNMENT</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>
See
{{domxref("WebGLRenderingContext/pixelStorei", "pixelStorei")}}.
</td>
</tr>
<tr>
<td><code>gl.UNPACK_IMAGE_HEIGHT</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>
See
{{domxref("WebGLRenderingContext/pixelStorei", "pixelStorei")}}.
</td>
</tr>
<tr>
<td><code>gl.UNPACK_ROW_LENGTH</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>
See
{{domxref("WebGLRenderingContext/pixelStorei", "pixelStorei")}}.
</td>
</tr>
<tr>
<td><code>gl.UNPACK_SKIP_IMAGES</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>
See
{{domxref("WebGLRenderingContext/pixelStorei", "pixelStorei")}}.
</td>
</tr>
<tr>
<td><code>gl.UNPACK_SKIP_PIXELS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>
See
{{domxref("WebGLRenderingContext/pixelStorei", "pixelStorei")}}.
</td>
</tr>
<tr>
<td><code>gl.UNPACK_SKIP_ROWS</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>
See
{{domxref("WebGLRenderingContext/pixelStorei", "pixelStorei")}}.
</td>
</tr>
<tr>
<td><code>gl.VERTEX_ARRAY_BINDING</code></td>
<td>
{{domxref("WebGLVertexArrayObject")}} or <code>null</code>
</td>
<td>
See
{{domxref("WebGL2RenderingContext/bindVertexArray", "bindVertexArray")}}.
</td>
</tr>
</tbody>
</table>
### WebGL extensions
You can query the following `pname` parameters when using [WebGL extensions](/en-US/docs/Web/API/WebGL_API/Using_Extensions):
<table class="no-markdown">
<thead>
<tr>
<th scope="col">Constant</th>
<th scope="col">Returned type</th>
<th scope="col">Extension</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT</code></td>
<td>{{domxref("WebGL_API/Types", "GLfloat")}}</td>
<td>{{domxref("EXT_texture_filter_anisotropic")}}</td>
<td>Maximum available anisotropy.</td>
</tr>
<tr>
<td><code>ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES</code></td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>{{domxref("OES_standard_derivatives")}}</td>
<td>
Accuracy of the derivative calculation for the GLSL built-in functions:
<code>dFdx</code>, <code>dFdy</code>, and <code>fwidth</code>.
</td>
</tr>
<tr>
<td><code>ext.MAX_COLOR_ATTACHMENTS_WEBGL</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>{{domxref("WEBGL_draw_buffers")}}</td>
<td>The maximum number of framebuffer color attachment points.</td>
</tr>
<tr>
<td><code>ext.MAX_DRAW_BUFFERS_WEBGL</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>{{domxref("WEBGL_draw_buffers")}}</td>
<td>The maximum number of draw buffers.</td>
</tr>
<tr>
<td>
<code
>ext.DRAW_BUFFER0_WEBGL<br />ext.DRAW_BUFFER1_WEBGL<br />ext.DRAW_BUFFER2_WEBGL<br />ext.DRAW_BUFFER3_WEBGL<br />ext.DRAW_BUFFER4_WEBGL<br />ext.DRAW_BUFFER5_WEBGL<br />ext.DRAW_BUFFER6_WEBGL<br />ext.DRAW_BUFFER7_WEBGL<br />ext.DRAW_BUFFER8_WEBGL<br />ext.DRAW_BUFFER9_WEBGL<br />ext.DRAW_BUFFER10_WEBGL<br />ext.DRAW_BUFFER11_WEBGL<br />ext.DRAW_BUFFER12_WEBGL<br />ext.DRAW_BUFFER13_WEBGL<br />ext.DRAW_BUFFER14_WEBGL<br />ext.DRAW_BUFFER15_WEBGL</code
>
</td>
<td>{{domxref("WebGL_API/Types", "GLenum")}}</td>
<td>{{domxref("WEBGL_draw_buffers")}}</td>
<td>Drawing buffers.</td>
</tr>
<tr>
<td><code>ext.VERTEX_ARRAY_BINDING_OES</code></td>
<td>
{{domxref("WebGLVertexArrayObject", "WebGLVertexArrayObjectOES")}}
</td>
<td>{{domxref("OES_vertex_array_object")}}</td>
<td>Bound vertex array object (VAO).</td>
</tr>
<tr>
<td><code>ext.TIMESTAMP_EXT</code></td>
<td>{{domxref("WebGL_API/Types", "GLuint64EXT")}}</td>
<td><p>{{domxref("EXT_disjoint_timer_query")}}</p></td>
<td>The current time.</td>
</tr>
<tr>
<td><code>ext.GPU_DISJOINT_EXT</code></td>
<td>{{domxref("WebGL_API/Types", "GLboolean")}}</td>
<td>{{domxref("EXT_disjoint_timer_query")}}</td>
<td>
<p>Returns whether or not the GPU performed any disjoint operation.</p>
</td>
</tr>
<tr>
<td><code>ext.MAX_VIEWS_OVR</code></td>
<td>{{domxref("WebGL_API/Types", "GLint")}}</td>
<td>{{domxref("OVR_multiview2")}}</td>
<td>Maximum number of views.</td>
</tr>
</tbody>
</table>
## Examples
```js
gl.getParameter(gl.DITHER);
gl.getParameter(gl.VERSION);
gl.getParameter(gl.VIEWPORT);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.enable()")}}
- {{domxref("WebGLRenderingContext.disable()")}}
- {{domxref("EXT_texture_filter_anisotropic")}}
- {{domxref("OES_standard_derivatives")}}
- {{domxref("WEBGL_draw_buffers")}}
- {{domxref("EXT_disjoint_timer_query")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/depthfunc/index.md | ---
title: "WebGLRenderingContext: depthFunc() method"
short-title: depthFunc()
slug: Web/API/WebGLRenderingContext/depthFunc
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.depthFunc
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.depthFunc()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specifies a function that compares
incoming pixel depth to the current depth buffer value.
## Syntax
```js-nolint
depthFunc(func)
```
### Parameters
- `func`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the depth comparison function, which sets the
conditions under which the pixel will be drawn. The default value is
`gl.LESS`. Possible values are:
- `gl.NEVER` (never pass)
- `gl.LESS` (pass if the incoming value is less than the depth buffer
value)
- `gl.EQUAL` (pass if the incoming value equals the depth buffer value)
- `gl.LEQUAL` (pass if the incoming value is less than or equal to the
depth buffer value)
- `gl.GREATER` (pass if the incoming value is greater than the depth
buffer value)
- `gl.NOTEQUAL` (pass if the incoming value is not equal to the depth
buffer value)
- `gl.GEQUAL` (pass if the incoming value is greater than or equal to
the depth buffer value)
- `gl.ALWAYS` (always pass)
### Return value
None ({{jsxref("undefined")}}).
## Examples
The depth testing is disabled by default. To enable or disable depth testing, use the
{{domxref("WebGLRenderingContext.enable", "enable()")}} and
{{domxref("WebGLRenderingContext.disable", "disable()")}} methods with the argument
`gl.DEPTH_TEST`.
```js
gl.enable(gl.DEPTH_TEST);
gl.depthFunc(gl.NEVER);
```
To check the current depth function, query the `DEPTH_FUNC` constant.
```js
gl.getParameter(gl.DEPTH_FUNC) === gl.NEVER;
// true
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.enable()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getvertexattriboffset/index.md | ---
title: "WebGLRenderingContext: getVertexAttribOffset() method"
short-title: getVertexAttribOffset()
slug: Web/API/WebGLRenderingContext/getVertexAttribOffset
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getVertexAttribOffset
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.getVertexAttribOffset()`** method
of the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns the address of a
specified vertex attribute.
## Syntax
```js-nolint
getVertexAttribOffset(index, pname)
```
### Parameters
- `index`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the index of the vertex attribute.
- `pname`
- : A {{domxref("WebGL_API/Types", "GLenum")}} which must be `gl.VERTEX_ATTRIB_ARRAY_POINTER`.
### Return value
A {{domxref("WebGL_API/Types", "GLintptr")}} indicating the address of the vertex attribute.
## Examples
```js
gl.getVertexAttribOffset(i, gl.VERTEX_ATTRIB_ARRAY_POINTER);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.vertexAttribPointer()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/scissor/index.md | ---
title: "WebGLRenderingContext: scissor() method"
short-title: scissor()
slug: Web/API/WebGLRenderingContext/scissor
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.scissor
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.scissor()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) sets a scissor box, which limits
the drawing to a specified rectangle.
## Syntax
```js-nolint
scissor(x, y, width, height)
```
### Parameters
- `x`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the horizontal coordinate for the lower left
corner of the box. Default value: 0.
- `y`
- : A {{domxref("WebGL_API/Types", "GLint")}} specifying the vertical coordinate for the lower left corner
of the box. Default value: 0.
- `width`
- : A non-negative {{domxref("WebGL_API/Types", "GLsizei")}} specifying the width of the scissor box.
Default value: width of the canvas.
- `height`
- : A non-negative {{domxref("WebGL_API/Types", "GLsizei")}} specifying the height of the scissor box.
Default value: height of the canvas.
### Return value
None ({{jsxref("undefined")}}).
### Exceptions
If either _width_ or _height_ is a negative value, a
`gl.INVALID_VALUE` error is thrown.
## Examples
When the scissor test is enabled, only pixels within the scissor box can be modified by
drawing commands.
```js
// turn on scissor test
gl.enable(gl.SCISSOR_TEST);
// set the scissor rectangle
gl.scissor(x, y, width, height);
// execute drawing commands in the scissor box (e.g. clear)
// turn off scissor test again
gl.disable(gl.SCISSOR_TEST);
```
To get the current scissor box dimensions, query the `SCISSOR_BOX` constant
which returns an {{jsxref("Int32Array")}}.
```js
gl.scissor(0, 0, 200, 200);
gl.getParameter(gl.SCISSOR_BOX);
// Int32Array[0, 0, 200, 200]
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.viewport()")}}
- {{domxref("WebGLRenderingContext.enable()")}}
- {{domxref("WebGLRenderingContext.disable()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/linewidth/index.md | ---
title: "WebGLRenderingContext: lineWidth() method"
short-title: lineWidth()
slug: Web/API/WebGLRenderingContext/lineWidth
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.lineWidth
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.lineWidth()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) sets the line width of rasterized
lines.
> **Warning:** The webgl spec, based on the OpenGL ES 2.0/3.0 specs points out that the minimum and
> maximum width for a line is implementation defined. The maximum minimum width is
> allowed to be 1.0. The minimum maximum width is also allowed to be 1.0. Because of
> these implementation defined limits it is not recommended to use line widths other
> than 1.0 since there is no guarantee any user's browser will display any other width.
>
> As of January 2017 most implementations of WebGL only support a minimum of 1 and a
> maximum of 1 as the technology they are based on has these same limits.
## Syntax
```js-nolint
lineWidth(width)
```
### Parameters
- `width`
- : A {{domxref("WebGL_API/Types", "GLfloat")}} specifying the width of rasterized lines. Default value: 1.
### Return value
None ({{jsxref("undefined")}}).
## Examples
Setting the line width:
```js
gl.lineWidth(5);
```
Getting the line width:
```js
gl.getParameter(gl.LINE_WIDTH);
```
Getting the range of available widths. Returns a {{jsxref("Float32Array")}}.
```js
gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/depthrange/index.md | ---
title: "WebGLRenderingContext: depthRange() method"
short-title: depthRange()
slug: Web/API/WebGLRenderingContext/depthRange
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.depthRange
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.depthRange()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) specifies the depth range mapping
from normalized device coordinates to window or viewport coordinates.
## Syntax
```js-nolint
depthRange(zNear, zFar)
```
### Parameters
- `zNear`
- : A {{domxref("WebGL_API/Types", "GLclampf")}} specifying the mapping of the near clipping plane to
window or viewport coordinates. Clamped to the range 0 to 1 and must be less than or
equal to `zFar`. The default value i`s 0.`
- `zFar`
- : A {{domxref("WebGL_API/Types", "GLclampf")}} specifying the mapping of the far clipping plane to window
or viewport coordinates. Clamped to the range 0 to 1. The default value
i`s 1.`
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.depthRange(0.2, 0.6);
```
To check the current depth range, query the `DEPTH_RANGE` constant which
returns a {{jsxref("Float32Array")}}
```js
gl.getParameter(gl.DEPTH_RANGE);
// Float32Array[0.2, 0.6]
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.viewport()")}}
- {{domxref("WebGLRenderingContext.depthFunc()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/attachshader/index.md | ---
title: "WebGLRenderingContext: attachShader() method"
short-title: attachShader()
slug: Web/API/WebGLRenderingContext/attachShader
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.attachShader
---
{{APIRef("WebGL")}}
The **WebGLRenderingContext.attachShader()** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) attaches either a fragment or
vertex {{domxref("WebGLShader")}} to a {{domxref("WebGLProgram")}}.
## Syntax
```js-nolint
attachShader(program, shader)
```
### Parameters
- `program`
- : A {{domxref("WebGLProgram")}}.
- `shader`
- : A fragment or vertex {{domxref("WebGLShader")}}.
## Examples
The following code attaches pre-existing shaders to a {{domxref("WebGLProgram")}}.
```js
const program = gl.createProgram();
// Attach pre-existing shaders
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
const info = gl.getProgramInfoLog(program);
throw `Could not compile WebGL program. \n\n${info}`;
}
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLProgram")}}
- {{domxref("WebGLShader")}}
- {{domxref("WebGLRenderingContext.attachShader()")}}
- {{domxref("WebGLRenderingContext.compileShader()")}}
- {{domxref("WebGLRenderingContext.createProgram()")}}
- {{domxref("WebGLRenderingContext.createShader()")}}
- {{domxref("WebGLRenderingContext.deleteProgram()")}}
- {{domxref("WebGLRenderingContext.deleteShader()")}}
- {{domxref("WebGLRenderingContext.detachShader()")}}
- {{domxref("WebGLRenderingContext.getAttachedShaders()")}}
- {{domxref("WebGLRenderingContext.getProgramParameter()")}}
- {{domxref("WebGLRenderingContext.getProgramInfoLog()")}}
- {{domxref("WebGLRenderingContext.getShaderParameter()")}}
- {{domxref("WebGLRenderingContext.getShaderPrecisionFormat()")}}
- {{domxref("WebGLRenderingContext.getShaderInfoLog()")}}
- {{domxref("WebGLRenderingContext.getShaderSource()")}}
- {{domxref("WebGLRenderingContext.isProgram()")}}
- {{domxref("WebGLRenderingContext.isShader()")}}
- {{domxref("WebGLRenderingContext.linkProgram()")}}
- {{domxref("WebGLRenderingContext.shaderSource()")}}
- {{domxref("WebGLRenderingContext.useProgram()")}}
- {{domxref("WebGLRenderingContext.validateProgram()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/getframebufferattachmentparameter/index.md | ---
title: "WebGLRenderingContext: getFramebufferAttachmentParameter() method"
short-title: getFramebufferAttachmentParameter()
slug: Web/API/WebGLRenderingContext/getFramebufferAttachmentParameter
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.getFramebufferAttachmentParameter
---
{{APIRef("WebGL")}}
The
**`WebGLRenderingContext.getFramebufferAttachmentParameter()`**
method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns information
about a framebuffer's attachment.
## Syntax
```js-nolint
getFramebufferAttachmentParameter(target, attachment, pname)
```
### Parameters
- `target`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the binding point (target). Possible values:
- `gl.FRAMEBUFFER`
- : Collection buffer data storage of color, alpha,
depth and stencil buffers used to render an image.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.DRAW_FRAMEBUFFER`
- : Equivalent to `gl.FRAMEBUFFER`.
Used as a destination for drawing, rendering, clearing, and writing operations.
- `gl.READ_FRAMEBUFFER`
- : Used as a source for reading operations.
- `attachment`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying the attachment point for the
`texture`. Possible values:
- `gl.COLOR_ATTACHMENT0`: Texture attachment for the framebuffer's
color buffer.
- `gl.DEPTH_ATTACHMENT`: Texture attachment for the framebuffer's depth
buffer.
- `gl.STENCIL_ATTACHMENT`: Texture attachment for the framebuffer's
stencil buffer.
- `gl.DEPTH_STENCIL_ATTACHMENT`: Texture attachment for both, the depth
and stencil buffer.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.COLOR_ATTACHMENT1 gl.COLOR_ATTACHMENT2 gl.COLOR_ATTACHMENT3 gl.COLOR_ATTACHMENT4 gl.COLOR_ATTACHMENT5 gl.COLOR_ATTACHMENT6 gl.COLOR_ATTACHMENT7 gl.COLOR_ATTACHMENT8 gl.COLOR_ATTACHMENT9 gl.COLOR_ATTACHMENT10 gl.COLOR_ATTACHMENT11 gl.COLOR_ATTACHMENT12 gl.COLOR_ATTACHMENT13 gl.COLOR_ATTACHMENT14 gl.COLOR_ATTACHMENT15`
When using the {{domxref("WEBGL_draw_buffers")}} extension:
- `ext.COLOR_ATTACHMENT0_WEBGL` (same as
`gl.COLOR_ATTACHMENT0`)
`ext.COLOR_ATTACHMENT1_WEBGL ext.COLOR_ATTACHMENT2_WEBGL ext.COLOR_ATTACHMENT3_WEBGL ext.COLOR_ATTACHMENT4_WEBGL ext.COLOR_ATTACHMENT5_WEBGL ext.COLOR_ATTACHMENT6_WEBGL ext.COLOR_ATTACHMENT7_WEBGL ext.COLOR_ATTACHMENT8_WEBGL ext.COLOR_ATTACHMENT9_WEBGL ext.COLOR_ATTACHMENT10_WEBGL ext.COLOR_ATTACHMENT11_WEBGL ext.COLOR_ATTACHMENT12_WEBGL ext.COLOR_ATTACHMENT13_WEBGL ext.COLOR_ATTACHMENT14_WEBGL ext.COLOR_ATTACHMENT15_WEBGL`
- `pname`
- : A {{domxref("WebGL_API/Types", "GLenum")}} specifying information to query. Possible values:
- `gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE`: The type which contains the
attached image.
- `gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME`: The texture or renderbuffer
of the attached image ({{domxref("WebGLRenderbuffer")}} or
{{domxref("WebGLTexture")}}).
- `gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL`: Mipmap level. Default
value: 0.
- `gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE`: The name of
cube-map face of the texture.
When using the {{domxref("EXT_sRGB")}} extension:
- `ext.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT`: The framebuffer
color encoding.
When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}},
the following values are available additionally:
- `gl.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE`
- `gl.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE`
- `gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING`
- `gl.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE`
- `gl.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE`
- `gl.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE`
- `gl.FRAMEBUFFER_ATTACHMENT_RED_SIZE`
- `gl.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE`
- `gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER`
When using the {{domxref("OVR_multiview2")}} extension:
- `ext.FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR`: the number of views of the framebuffer object attachment.
- `ext.FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR`: the base view index of the framebuffer object attachment.
### Return value
Depends on the requested information (as specified with `pname`). Either a
{{domxref("WebGL_API/Types", "GLint")}}, a {{domxref("WebGL_API/Types", "GLenum")}}, a {{domxref("WebGLRenderbuffer")}}, or a
{{domxref("WebGLTexture")}}.
<table class="standard-table">
<thead>
<tr>
<th scope="col"><code>pname</code> parameter</th>
<th scope="col">Return value</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLenum")}} indicating the
type of the texture. Either <code>gl.RENDERBUFFER</code>,
<code>gl.TEXTURE</code>, or if no image is attached,
<code>gl.NONE</code>.
</td>
</tr>
<tr>
<td><code>gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME</code></td>
<td>
The texture ({{domxref("WebGLTexture")}}) or renderbuffer
({{domxref("WebGLRenderbuffer")}}) of the attached image.
</td>
</tr>
<tr>
<td><code>gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLint")}} indicating the
mipmap level. Default value: 0.
</td>
</tr>
<tr>
<td><code>gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLenum")}} indicating the
name of cube-map face of the texture. Possible values:
<ul>
<li>
<code>gl.TEXTURE_CUBE_MAP_POSITIVE_X</code>: Image for the positive
X face of the cube.
</li>
<li>
<code>gl.TEXTURE_CUBE_MAP_NEGATIVE_X</code>: Image for the negative
X face of the cube.
</li>
<li>
<code>gl.TEXTURE_CUBE_MAP_POSITIVE_Y</code>: Image for the positive
Y face of the cube.
</li>
<li>
<code>gl.TEXTURE_CUBE_MAP_NEGATIVE_Y</code>: Image for the negative
Y face of the cube.
</li>
<li>
<code>gl.TEXTURE_CUBE_MAP_POSITIVE_Z</code>: Image for the positive
Z face of the cube.
</li>
<li>
<code>gl.TEXTURE_CUBE_MAP_NEGATIVE_Z</code>: Image for the negative
Z face of the cube.
</li>
</ul>
</td>
</tr>
<tr>
<td><code>gl.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLint")}} indicating the
number of bits in the alpha component of the attachment.
</td>
</tr>
<tr>
<td><code>gl.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLint")}} indicating the
number of bits in the blue component of the attachment.
</td>
</tr>
<tr>
<td><code>gl.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLenum")}} indicating the
encoding of components of the specified attachment. Either
<code>gl.LINEAR</code> or <code>gl.SRGB</code>.
</td>
</tr>
<tr>
<td><code>gl.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLenum")}} indicating the
format of the components of the specified attachment. Either
<code>gl.FLOAT</code>, <code>gl.INT</code>,
<code>gl.UNSIGNED_INT</code>, <code>gl.SIGNED_NORMALIZED</code>, or
<code>gl.UNSIGNED_NORMALIZED</code>.
</td>
</tr>
<tr>
<td><code>gl.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLint")}} indicating the
number of bits in the depth component of the attachment.
</td>
</tr>
<tr>
<td><code>gl.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLint")}} indicating the
number of bits in the green component of the attachment.
</td>
</tr>
<tr>
<td><code>gl.FRAMEBUFFER_ATTACHMENT_RED_SIZE</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLint")}} indicating the
number of bits in the red component of the attachment.
</td>
</tr>
<tr>
<td><code>gl.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLint")}} indicating the
number of bits in the stencil component of the attachment.
</td>
</tr>
<tr>
<td><code>gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLint")}} indicating the
number of the texture layer which contains the attached image.
</td>
</tr>
<tr>
<td><code>ext.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLenum")}} indicating the
framebuffer color encoding. Either <code>gl.LINEAR</code> or
<code>ext.SRGB_EXT</code>.
</td>
</tr>
<tr>
<td><code>ext.FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR</code></td>
<td>
A {{domxref("WebGL_API/Types", "GLsizei")}} indicating
the number of views of the framebuffer object attachment.
</td>
</tr>
<tr>
<td>
<code>ext.FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR</code>
</td>
<td>
A {{domxref("WebGL_API/Types", "GLint")}} indicating the
base view index of the framebuffer object attachment.
</td>
</tr>
</tbody>
</table>
### Exceptions
- A `gl.INVALID_ENUM` error is thrown if `target` is not
`gl.FRAMEBUFFER`, `gl.DRAW_FRAMEBUFFER`,
`gl.READ_FRAMEBUFFER` or if `attachment` is not one of the
accepted attachment points.
## Examples
```js
gl.getFramebufferAttachmentParameter(
gl.FRAMEBUFFER,
gl.COLOR_ATTACHMENT0,
gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.createFramebuffer()")}}
- {{domxref("WebGLRenderingContext.deleteFramebuffer()")}}
- {{domxref("WebGLRenderingContext.isFramebuffer()")}}
- Other buffers: {{domxref("WebGLBuffer")}}, {{domxref("WebGLRenderbuffer")}}
- {{domxref("EXT_sRGB")}}
- {{domxref("WEBGL_draw_buffers")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/istexture/index.md | ---
title: "WebGLRenderingContext: isTexture() method"
short-title: isTexture()
slug: Web/API/WebGLRenderingContext/isTexture
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.isTexture
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.isTexture()`** method of the [WebGL API](/en-US/docs/Web/API/WebGL_API) returns `true` if the
passed {{domxref("WebGLTexture")}} is valid and `false` otherwise.
## Syntax
```js-nolint
isTexture(texture)
```
### Parameters
- `texture`
- : A {{domxref("WebGLTexture")}} to check.
### Return value
A {{domxref("WebGL_API/Types", "GLboolean")}} indicating whether or not the texture is valid.
## Examples
### Checking a texture
```js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
const texture = gl.createTexture();
gl.isTexture(texture);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.bindTexture()")}}
- {{domxref("WebGLRenderingContext.createTexture()")}}
- {{domxref("WebGLRenderingContext.deleteTexture()")}}
- {{domxref("WebGLRenderingContext.texImage2D()")}}
| 0 |
data/mdn-content/files/en-us/web/api/webglrenderingcontext | data/mdn-content/files/en-us/web/api/webglrenderingcontext/bindattriblocation/index.md | ---
title: "WebGLRenderingContext: bindAttribLocation() method"
short-title: bindAttribLocation()
slug: Web/API/WebGLRenderingContext/bindAttribLocation
page-type: web-api-instance-method
browser-compat: api.WebGLRenderingContext.bindAttribLocation
---
{{APIRef("WebGL")}}
The **`WebGLRenderingContext.bindAttribLocation()`** method of
the [WebGL API](/en-US/docs/Web/API/WebGL_API) binds a generic vertex index
to an attribute variable.
## Syntax
```js-nolint
bindAttribLocation(program, index, name)
```
### Parameters
- `program`
- : A {{domxref("WebGLProgram")}} object to bind.
- `index`
- : A {{domxref("WebGL_API/Types", "GLuint")}} specifying the index of the generic vertex to bind.
- `name`
- : A string specifying the name of the variable to bind to the
generic vertex index. This name cannot start with "webgl\_" or "\_webgl\_", as these are
reserved for use by WebGL.
### Return value
None ({{jsxref("undefined")}}).
## Examples
```js
gl.bindAttribLocation(program, colorLocation, "vColor");
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("WebGLRenderingContext.getActiveAttrib()")}}
- {{domxref("WebGLRenderingContext.getAttribLocation()")}}
- {{domxref("WebGLRenderingContext.getVertexAttrib()")}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/gpucompilationinfo/index.md | ---
title: GPUCompilationInfo
slug: Web/API/GPUCompilationInfo
page-type: web-api-interface
status:
- experimental
browser-compat: api.GPUCompilationInfo
---
{{APIRef("WebGPU API")}}{{SeeCompatTable}}{{SecureContext_Header}}
The **`GPUCompilationInfo`** interface of the {{domxref("WebGPU API", "WebGPU API", "", "nocode")}} represents an array of {{domxref("GPUCompilationMessage")}} objects generated by the GPU shader module compiler to help diagnose problems with shader code.
`GPUCompilationInfo` is accessed via {{domxref("GPUShaderModule.getCompilationInfo()")}}.
{{InheritanceDiagram}}
## Instance properties
- {{domxref("GPUCompilationInfo.messages", "messages")}} {{Experimental_Inline}} {{ReadOnlyInline}}
- : An array of {{domxref("GPUCompilationMessage")}} objects, each one containing the details of an individual shader compilation message. Messages can be informational, warnings, or errors.
## Examples
In the example below, we have deliberately left a parenthesis out of a function declaration in our shader code:
```js
const shaders = `
struct VertexOut {
@builtin(position) position : vec4f,
@location(0) color : vec4f
}
@vertex
fn vertex_main(@location(0) position: vec4f,
@location(1) color: vec4f -> VertexOut
{
var output : VertexOut;
output.position = position;
output.color = color;
return output;
}
@fragment
fn fragment_main(fragData: VertexOut) -> @location(0) vec4f
{
return fragData.color;
}
`;
```
When we compile the shader module, we use `getCompilationInfo()` to grab some information about the resulting error:
```js
async function init() {
// ...
const shaderModule = device.createShaderModule({
code: shaders,
});
const shaderInfo = await shaderModule.getCompilationInfo();
const firstMessage = shaderInfo.messages[0];
console.log(firstMessage.lineNum); // 9
console.log(firstMessage.message); // "expected ')' for function declaration"
console.log(firstMessage.type); // "error"
// ...
}
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- The [WebGPU API](/en-US/docs/Web/API/WebGPU_API)
| 0 |
data/mdn-content/files/en-us/web/api/gpucompilationinfo | data/mdn-content/files/en-us/web/api/gpucompilationinfo/messages/index.md | ---
title: "GPUCompilationInfo: messages property"
short-title: messages
slug: Web/API/GPUCompilationInfo/messages
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.GPUCompilationInfo.messages
---
{{APIRef("WebGPU API")}}{{SeeCompatTable}}{{SecureContext_Header}}
The **`messages`** read-only property of the
{{domxref("GPUCompilationInfo")}} interface is an array of {{domxref("GPUCompilationMessage")}} objects, each one containing the details of an individual shader compilation message. Messages can be informational, warnings, or errors.
## Value
An array of {{domxref("GPUCompilationMessage")}} objects.
## Examples
See the main [`GPUCompilationInfo` page](/en-US/docs/Web/API/GPUCompilationInfo#examples) for an example.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- The [WebGPU API](/en-US/docs/Web/API/WebGPU_API)
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/dragevent/index.md | ---
title: DragEvent
slug: Web/API/DragEvent
page-type: web-api-interface
browser-compat: api.DragEvent
---
{{APIRef("HTML Drag and Drop API")}}
The **`DragEvent`** interface is a {{domxref("Event","DOM event")}} that represents a drag and drop interaction. The user initiates a drag by placing a pointer device (such as a mouse) on the touch surface and then dragging the pointer to a new location (such as another DOM element). Applications are free to interpret a drag and drop interaction in an application-specific way.
This interface inherits properties from {{domxref("MouseEvent")}} and {{domxref("Event")}}.
{{InheritanceDiagram}}
## Instance properties
- {{domxref('DragEvent.dataTransfer')}} {{ReadOnlyInline}}
- : The data that is transferred during a drag and drop interaction.
## Constructors
Although this interface has a constructor, it is not possible to create a useful DataTransfer object from script, since {{domxref("DataTransfer")}} objects have a processing and security model that is coordinated by the browser during drag-and-drops.
- {{domxref("DragEvent.DragEvent", "DragEvent()")}}
- : Creates a synthetic and untrusted DragEvent.
## Event types
- {{domxref("HTMLElement/drag_event", "drag")}}
- : This event is fired when an element or text selection is being dragged.
- {{domxref("HTMLElement/dragend_event", "dragend")}}
- : This event is fired when a drag operation is being ended (by releasing a mouse button or hitting the escape key).
- {{domxref("HTMLElement/dragenter_event", "dragenter")}}
- : This event is fired when a dragged element or text selection enters a valid drop target.
- {{domxref("HTMLElement/dragleave_event", "dragleave")}}
- : This event is fired when a dragged element or text selection leaves a valid drop target.
- {{domxref("HTMLElement/dragover_event", "dragover")}}
- : This event is fired continuously when an element or text selection is being dragged and the mouse pointer is over a valid drop target (every 50 ms WHEN mouse is not moving ELSE much faster between 5 ms (slow movement) and 1ms (fast movement) approximately. This firing pattern is different than {{domxref("Element/mouseover_event", "mouseover")}} ).
- {{domxref("HTMLElement/dragstart_event", "dragstart")}}
- : This event is fired when the user starts dragging an element or text selection.
- {{domxref("HTMLElement/drop_event", "drop")}}
- : This event is fired when an element or text selection is dropped on a valid drop target.
## Example
An Example of each property, constructor, event type and global event handlers is included in their respective reference page.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Drag and drop](/en-US/docs/Web/API/HTML_Drag_and_Drop_API)
- [Drag Operations](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations)
- [Recommended Drag Types](/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types)
- [DataTransfer test - Paste or Drag](https://codepen.io/tech_query/pen/MqGgap)
| 0 |
data/mdn-content/files/en-us/web/api/dragevent | data/mdn-content/files/en-us/web/api/dragevent/datatransfer/index.md | ---
title: "DragEvent: dataTransfer property"
short-title: dataTransfer
slug: Web/API/DragEvent/dataTransfer
page-type: web-api-instance-property
browser-compat: api.DragEvent.dataTransfer
---
{{APIRef("HTML Drag and Drop API")}}
The **`DragEvent.dataTransfer`** read-only property holds the drag
operation's data (as a {{domxref("DataTransfer")}} object).
## Value
A {{domxref("DataTransfer")}} object which contains the {{domxref("DragEvent","drag event's data")}}.
## Examples
This example illustrates accessing the drag and drop data within the
{{domxref("HTMLElement/dragend_event", "dragend")}} event handler.
```js
function processData(d) {
// Process the data …
}
dragTarget.addEventListener(
"dragend",
(ev) => {
// Call the drag and drop data processor
if (ev.dataTransfer !== null) processData(ev.dataTransfer);
},
false,
);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/dragevent | data/mdn-content/files/en-us/web/api/dragevent/dragevent/index.md | ---
title: "DragEvent: DragEvent() constructor"
short-title: DragEvent()
slug: Web/API/DragEvent/DragEvent
page-type: web-api-constructor
browser-compat: api.DragEvent.DragEvent
---
{{APIRef("HTML Drag and Drop API")}}
This constructor is used to create a synthetic {{domxref("DragEvent")}} object.
Although this interface has a constructor, it is not possible to create a
useful {{domxref("DataTransfer")}} object from script, since {{domxref("DataTransfer")}}
objects have a processing and security model that is coordinated by the browser during
drag-and-drops.
This interface inherits properties from {{domxref("MouseEvent")}} and
{{domxref("Event")}}.
## Syntax
```js-nolint
new DragEvent(type)
new DragEvent(type, dragEventInit)
```
### Parameters
- `type`
- : A string representing the name of the event (see [DragEvent event types](/en-US/docs/Web/API/DragEvent#event_types)).
- `eventInitDict` {{optional_inline}}
- : An object containing the following properties:
- `dataTransfer` {{optional_inline}}
- : A {{domxref("DataTransfer")}}. Defaults to `null`.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/xrreferencespaceevent/index.md | ---
title: XRReferenceSpaceEvent
slug: Web/API/XRReferenceSpaceEvent
page-type: web-api-interface
browser-compat: api.XRReferenceSpaceEvent
---
{{APIRef("WebXR Device API")}}{{SecureContext_header}}
The [WebXR Device API](/en-US/docs/Web/API/WebXR_Device_API) interface **`XRReferenceSpaceEvent`** represents an event sent to an {{domxref("XRReferenceSpace")}}. Currently, the only event that uses this type is the {{domxref("XRReferenceSpace.reset_event", "reset")}} event.
{{InheritanceDiagram}}
## Constructor
- {{domxref("XRReferenceSpaceEvent.XRReferenceSpaceEvent", "XRReferenceSpaceEvent()")}}
- : Returns a new `XRReferenceSpaceEvent` with the specified type and configuration.
## Instance properties
_In addition to inheriting the properties available on the parent interface, {{domxref("Event")}}, `XRReferenceSpaceEvent` objects include the following properties:_
- {{domxref("XRReferenceSpaceEvent.referenceSpace", "referenceSpace")}} {{ReadOnlyInline}}
- : An {{domxref("XRReferenceSpace")}} indicating the reference space that generated the event.
- {{domxref("XRReferenceSpaceEvent.transform", "transform")}} {{ReadOnlyInline}}
- : An {{domxref("XRRigidTransform")}} object indicating the position and orientation of the specified `referenceSpace`'s native origin after the event, defined relative to the coordinate system before the event.
## Instance methods
_While `XRReferenceSpaceEvent` does not define any methods, it inherits the methods of its parent interface, {{domxref("Event")}}._
## Event types
- {{domxref("XRReferenceSpace.reset_event", "reset")}}
- : The `reset` event is sent to a reference space when its native origin is changed due to a discontinuity, recalibration, or device reset. This is an opportunity for your app to update any stored transforms, position/orientation information, or the like—or to dump any cached values based on the reference's space's origin so you can recompute them as needed.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/xrreferencespaceevent | data/mdn-content/files/en-us/web/api/xrreferencespaceevent/transform/index.md | ---
title: "XRReferenceSpaceEvent: transform property"
short-title: transform
slug: Web/API/XRReferenceSpaceEvent/transform
page-type: web-api-instance-property
browser-compat: api.XRReferenceSpaceEvent.transform
---
{{APIRef("WebXR Device API")}}{{SecureContext_Header}}
The read-only {{domxref("XRReferenceSpaceEvent")}} property
**`transform`** indicates the position and orientation of the
affected {{domxref("XRReferenceSpaceEvent.referenceSpace", "referenceSpace")}}'s
native origin after the changes the event represents are applied. The
`transform` is defined using the old coordinate system, which allows it to be
used to convert coordinates from the pre-event coordinate system to the post-event
coordinate system.
## Value
An {{domxref("XRRigidTransform")}} object providing a transform that can be used to
convert coordinates from the pre-event coordinate system to the post-event coordinate
system.
## Usage notes
Upon receiving a `reset` event, you can apply the `transform` to
cached position or orientation information to shift them into the updated coordinate
system. Alternatively, you can just discard any cached positional information and
recompute from scratch. The approach you take will depend on your needs.
For details on what causes a `reset` event and how to respond, see the
{{domxref("XRReferenceSpace.reset_event", "reset")}} event's documentation.
## Examples
This example handles the `reset` event by walking through all the objects in
a scene, updating each object's position by multiplying it with the event's given
`transform`. The scene is represented by a `scene` object, with
all the objects in an array called `objects` within it.
```js
xrReferenceSpace.addEventListener("reset", (event) => {
for (const obj of scene.objects) {
mat4.multiply(obj.transform, obj.transform, event.transform);
}
});
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/xrreferencespaceevent | data/mdn-content/files/en-us/web/api/xrreferencespaceevent/xrreferencespaceevent/index.md | ---
title: "XRReferenceSpaceEvent: XRReferenceSpaceEvent() constructor"
short-title: XRReferenceSpaceEvent()
slug: Web/API/XRReferenceSpaceEvent/XRReferenceSpaceEvent
page-type: web-api-constructor
browser-compat: api.XRReferenceSpaceEvent.XRReferenceSpaceEvent
---
{{APIRef("WebXR Device API")}}{{SecureContext_Header}}
The **`XRReferenceSpaceEvent()`**
constructor is used to create a new {{domxref("XRReferenceSpaceEvent")}} object, which
represents an event regarding the state of a WebXR reference space object,
{{domxref("XRReferenceSpace")}}.
## Syntax
```js-nolint
new XRReferenceSpaceEvent(type, options)
```
### Parameters
- `type`
- : A string with the name of the event.
It is case-sensitive and browsers always set it to `reset`.
- `options`
- : An object that, _in addition of the properties defined in {{domxref("Event/Event", "Event()")}}_, can have the following properties:
- `referenceSpace`
- : The {{domxref("XRReferenceSpace")}} from which the event originates.
- `transform`
- : An {{domxref("XRRigidTransform")}} which maps the old coordinate system (from before the changes indicated by this event) to the new coordinate system.
### Return value
A new `XRReferenceSpaceEvent` object, initialized as defined by the input parameters.
## Examples
This simple snippet calls the constructor to create a new reference space event of type {{domxref("XRReferenceSpace.reset_event", "reset")}}.
```js
let refSpaceEvent = new XRReferenceSpaceEvent("reset", {
referenceSpace: myRefSpace,
transform: myTransform,
});
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/xrreferencespaceevent | data/mdn-content/files/en-us/web/api/xrreferencespaceevent/referencespace/index.md | ---
title: "XRReferenceSpaceEvent: referenceSpace property"
short-title: referenceSpace
slug: Web/API/XRReferenceSpaceEvent/referenceSpace
page-type: web-api-instance-property
browser-compat: api.XRReferenceSpaceEvent.referenceSpace
---
{{APIRef("WebXR Device API")}}{{SecureContext_Header}}
The read-only {{domxref("XRReferenceSpaceEvent")}} property
**`referenceSpace`** specifies the reference space which is the
originator of the event.
## Value
An {{domxref("XRReferenceSpace")}} indicating the source of the event.
## Examples
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/filereadersync/index.md | ---
title: FileReaderSync
slug: Web/API/FileReaderSync
page-type: web-api-interface
browser-compat: api.FileReaderSync
---
{{APIRef("File API")}}
The **`FileReaderSync`** interface allows to read {{DOMxRef("File")}} or {{DOMxRef("Blob")}} objects synchronously. This interface is [only available](/en-US/docs/Web/API/Web_Workers_API/Functions_and_classes_available_to_workers) in [workers](/en-US/docs/Web/API/Worker) as it enables synchronous I/O that could potentially block.
{{AvailableInWorkers}}
## Constructor
- {{domxref("FileReaderSync.FileReaderSync", "FileReaderSync()")}}
- : Returns a new `FileReaderSync` object.
## Instance properties
This interface does not have any properties.
## Instance methods
- {{DOMxRef("FileReaderSync.readAsArrayBuffer","FileReaderSync.readAsArrayBuffer()")}}
- : This method converts a specified {{DOMxRef("Blob")}} or a {{DOMxRef("File")}} into an {{jsxref("ArrayBuffer")}} representing the input data as a binary string.
- {{DOMxRef("FileReaderSync.readAsBinaryString","FileReaderSync.readAsBinaryString()")}} {{deprecated_inline}}
- : This method converts a specified {{DOMxRef("Blob")}} or a {{DOMxRef("File")}} into a string representing the input data as a binary string. This method is deprecated, consider using `readAsArrayBuffer()` instead.
- {{DOMxRef("FileReaderSync.readAsText","FileReaderSync.readAsText()")}}
- : This method converts a specified {{DOMxRef("Blob")}} or a {{DOMxRef("File")}} into a string representing the input data as a text string. The optional **`encoding`** parameter indicates the encoding to be used (e.g., iso-8859-1 or UTF-8). If not present, the method will apply a detection algorithm for it.
- {{DOMxRef("FileReaderSync.readAsDataURL","FileReaderSync.readAsDataURL()")}}
- : This method converts a specified {{DOMxRef("Blob")}} or a {{DOMxRef("File")}} into a string representing the input data as a data URL.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{DOMxRef("FileReader")}}
- {{DOMxRef("Blob")}}
- {{DOMxRef("File")}}
| 0 |
data/mdn-content/files/en-us/web/api/filereadersync | data/mdn-content/files/en-us/web/api/filereadersync/filereadersync/index.md | ---
title: "FileReaderSync: FileReaderSync() constructor"
short-title: FileReaderSync()
slug: Web/API/FileReaderSync/FileReaderSync
page-type: web-api-constructor
browser-compat: api.FileReaderSync.FileReaderSync
---
{{APIRef("File API")}}
The **`FileReaderSync()`** constructor creates a new {{domxref("FileReaderSync")}}.
{{AvailableInWorkers}}
## Syntax
```js-nolint
new FileReaderSync()
```
### Parameters
None.
## Examples
The following code snippet shows creation of a [`FileReaderSync`](/en-US/docs/Web/API/FileReaderSync) object using the `FileReaderSync()` constructor and subsequent usage of the object:
```js
function readFile(blob) {
const reader = new FileReaderSync();
postMessage(reader.readAsDataURL(blob));
}
```
> **Note:** This snippet must be used inside a {{domxref("Worker")}}, as synchronous interfaces can't be used on the main thread.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/filereadersync | data/mdn-content/files/en-us/web/api/filereadersync/readasdataurl/index.md | ---
title: "FileReaderSync: readAsDataURL() method"
short-title: readAsDataURL()
slug: Web/API/FileReaderSync/readAsDataURL
page-type: web-api-instance-method
browser-compat: api.FileReaderSync.readAsDataURL
---
{{APIRef("File API")}}
The **`readAsDataURL()`** method of the {{DOMxRef("FileReaderSync")}} interface allows to read {{DOMxRef("File")}} or {{DOMxRef("Blob")}} objects in a synchronous way into a string representing a data URL. This interface is [only available](/en-US/docs/Web/API/Web_Workers_API/Functions_and_classes_available_to_workers) in [workers](/en-US/docs/Web/API/Worker) as it enables synchronous I/O that could potentially block.
{{AvailableInWorkers}}
## Syntax
```js-nolint
readAsDataURL(File)
readAsDataURL(Blob)
```
### Parameters
- `blob`
- : The {{DOMxRef("File")}} or {{DOMxRef("Blob")}} to read.
### Return value
A string representing the input data as a data URL.
## Exceptions
The following exceptions can be raised by this method:
- `NotFoundError` {{domxref("DOMException")}}
- : Thrown if the resource represented by the DOM {{DOMxRef("File")}} or {{DOMxRef("Blob")}} cannot be found, e.g. because it has been erased.
- `SecurityError` {{domxref("DOMException")}}
- : Thrown if one of the following problematic situation is detected:
- the resource has been modified by a third party;
- too many read are performed simultaneously;
- the file pointed by the resource is unsafe for a use from the Web (like it is a system file).
- `NotReadableError` {{domxref("DOMException")}}
- : Thrown if the resource cannot be read due to a permission problem, like a concurrent lock.
- `EncodingError` {{domxref("DOMException")}}
- : Thrown if the resource is a data URL and exceed the limit length defined by each browser.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [File and Directory Entries API](/en-US/docs/Web/API/File_and_Directory_Entries_API)
- {{DOMxRef("File")}}
- {{DOMxRef("FileReaderSync")}}
- {{DOMxRef("FileReader")}}
- {{ domxref("Blob") }}
| 0 |
data/mdn-content/files/en-us/web/api/filereadersync | data/mdn-content/files/en-us/web/api/filereadersync/readastext/index.md | ---
title: "FileReaderSync: readAsText() method"
short-title: readAsText()
slug: Web/API/FileReaderSync/readAsText
page-type: web-api-instance-method
browser-compat: api.FileReaderSync.readAsText
---
{{APIRef("File API")}}
The **`readAsText()`** method of the {{DOMxRef("FileReaderSync")}} interface allows to read {{DOMxRef("File")}} or {{DOMxRef("Blob")}} objects in a synchronous way into a string. This interface is [only available](/en-US/docs/Web/API/Web_Workers_API/Functions_and_classes_available_to_workers) in [workers](/en-US/docs/Web/API/Worker) as it enables synchronous I/O that could potentially block.
{{AvailableInWorkers}}
## Syntax
```js-nolint
readAsText(File)
readAsText(Blob)
readAsText(File, encoding)
readAsText(Blob, encoding)
```
### Parameters
- `blob`
- : The {{DOMxRef("File")}} or {{DOMxRef("Blob")}} to read.
- `encoding`
- : The optional parameter specifies encoding to be used (e.g., `iso-8859-1` or `UTF-8`). If not present, the method will apply a detection algorithm for it.
### Return value
A string representing the input data.
## Exceptions
The following exceptions can be raised by this method:
- `NotFoundError` {{domxref("DOMException")}}
- : Thrown if the resource represented by the DOM {{DOMxRef("File")}} or {{DOMxRef("Blob")}} cannot be found, e.g. because it has been erased.
- `SecurityError` {{domxref("DOMException")}}
- : Thrown if one of the following problematic situation is detected:
- the resource has been modified by a third party;
- too many read are performed simultaneously;
- the file pointed by the resource is unsafe for a use from the Web (like it is a system file).
- `NotReadableError` {{domxref("DOMException")}}
- : Thrown if the resource cannot be read due to a permission problem, like a concurrent lock.
- `EncodingError` {{domxref("DOMException")}}
- : Thrown if the resource is a data URL and exceed the limit length defined by each browser.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [File API](/en-US/docs/Web/API/File_API)
- {{DOMxRef("File")}}
- {{DOMxRef("FileReaderSync")}}
- {{DOMxRef("FileReader")}}
- {{ domxref("Blob") }}
| 0 |
data/mdn-content/files/en-us/web/api/filereadersync | data/mdn-content/files/en-us/web/api/filereadersync/readasbinarystring/index.md | ---
title: "FileReaderSync: readAsBinaryString() method"
short-title: readAsBinaryString()
slug: Web/API/FileReaderSync/readAsBinaryString
page-type: web-api-instance-method
status:
- deprecated
browser-compat: api.FileReaderSync.readAsBinaryString
---
{{APIRef("File API")}}{{deprecated_header}}
> **Note:** This method is deprecated in favor of {{DOMxRef("FileReaderSync.readAsArrayBuffer","readAsArrayBuffer()")}}.
The **`readAsBinaryString()`** method of the {{DOMxRef("FileReaderSync")}} interface allows to read {{DOMxRef("File")}} or {{DOMxRef("Blob")}} objects in a synchronous way into a string. This interface is [only available](/en-US/docs/Web/API/Web_Workers_API/Functions_and_classes_available_to_workers) in [workers](/en-US/docs/Web/API/Worker) as it enables synchronous I/O that could potentially block.
{{AvailableInWorkers}}
## Syntax
```js-nolint
readAsBinaryString(File)
readAsBinaryString(Blob)
```
### Parameters
- `blob`
- : The {{DOMxRef("File")}} or {{DOMxRef("Blob")}} to read.
### Return value
A string representing the input data.
## Exceptions
- `NotFoundError` {{domxref("DOMException")}}
- : Thrown if the resource represented by the DOM {{DOMxRef("File")}} or {{DOMxRef("Blob")}} cannot be found, e.g. because it has been erased.
- `SecurityError` {{domxref("DOMException")}}
- : Thrown if one of the following problematic situation is detected:
- the resource has been modified by a third party;
- too many read are performed simultaneously;
- the file pointed by the resource is unsafe for a use from the Web (like it is a system file).
- `NotReadableError` {{domxref("DOMException")}}
- : Thrown if the resource cannot be read due to a permission problem, like a concurrent lock.
- `EncodingError` {{domxref("DOMException")}}
- : Thrown if the resource is a data URL and exceed the limit length defined by each browser.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [File API](/en-US/docs/Web/API/File_API)
- {{DOMxRef("File")}}
- {{DOMxRef("FileReaderSync")}}
- {{DOMxRef("FileReader")}}
- {{ domxref("Blob") }}
| 0 |
data/mdn-content/files/en-us/web/api/filereadersync | data/mdn-content/files/en-us/web/api/filereadersync/readasarraybuffer/index.md | ---
title: "FileReaderSync: readAsArrayBuffer() method"
short-title: readAsArrayBuffer()
slug: Web/API/FileReaderSync/readAsArrayBuffer
page-type: web-api-instance-method
browser-compat: api.FileReaderSync.readAsArrayBuffer
---
{{APIRef("File API")}}
The **`readAsArrayBuffer()`** method of the {{DOMxRef("FileReaderSync")}} interface allows to read {{DOMxRef("File")}} or {{DOMxRef("Blob")}} objects in a synchronous way into an {{jsxref("ArrayBuffer")}}. This interface is [only available](/en-US/docs/Web/API/Web_Workers_API/Functions_and_classes_available_to_workers) in [workers](/en-US/docs/Web/API/Worker) as it enables synchronous I/O that could potentially block.
{{AvailableInWorkers}}
## Syntax
```js-nolint
readAsArrayBuffer(blob)
```
### Parameters
- `blob`
- : The {{DOMxRef("File")}} or {{DOMxRef("Blob")}} to read into the {{DOMxRef("File")}} or {{jsxref("ArrayBuffer")}}.
### Return value
An {{jsxref("ArrayBuffer")}} representing the file's data.
## Exceptions
The following exceptions can be raised by this method:
- `NotFoundError` {{domxref("DOMException")}}
- : Thrown if the resource represented by the DOM {{DOMxRef("File")}} or {{DOMxRef("Blob")}} cannot be found, e.g. because it has been erased.
- `SecurityError` {{domxref("DOMException")}}
- : Thrown if one of the following problematic situation is detected:
- the resource has been modified by a third party;
- too many read are performed simultaneously;
- the file pointed by the resource is unsafe for a use from the Web (like it is a system file).
- `NotReadableError` {{domxref("DOMException")}}
- : Thrown if the resource cannot be read due to a permission problem, like a concurrent lock.
- `EncodingError` {{domxref("DOMException")}}
- : Thrown if the resource is a data URL and exceed the limit length defined by each browser.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{DOMxRef("File API", "", "", "nocode")}}
- {{DOMxRef("File")}}
- {{DOMxRef("FileReaderSync")}}
- {{DOMxRef("FileReader")}}
- {{DOMxRef("Blob")}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/usbconfiguration/index.md | ---
title: USBConfiguration
slug: Web/API/USBConfiguration
page-type: web-api-interface
status:
- experimental
browser-compat: api.USBConfiguration
---
{{securecontext_header}}{{APIRef("WebUSB API")}}{{SeeCompatTable}}
The `USBConfiguration` interface of the [WebUSB API](/en-US/docs/Web/API/WebUSB_API) provides information about a particular configuration of a USB device and the interfaces that it supports.
## Constructor
- {{domxref("USBConfiguration.USBConfiguration", "USBConfiguration()")}} {{Experimental_Inline}}
- : Creates a new `USBConfiguration` object which contains information about the configuration on the provided `USBDevice` with the given configuration value.
## Instance properties
- {{domxref("USBConfiguration.configurationValue")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Returns the configuration value of this configuration. This is equal to the [`bConfigurationValue`](https://www.beyondlogic.org/usbnutshell/usb5.shtml#ConfigurationDescriptors) field of the configuration descriptor provided by the device defining this configuration.
- {{domxref("USBConfiguration.configurationName")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Returns the name provided by the device to describe this configuration. This is equal to the value of the string descriptor with the index provided in the [`iConfiguration`](https://www.beyondlogic.org/usbnutshell/usb5.shtml#ConfigurationDescriptors) field of the configuration descriptor defining this configuration.
- {{domxref("USBConfiguration.interfaces")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Returns an array containing instances of the {{domxref('USBInterface')}} describing each interface supported by this configuration.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/usbconfiguration | data/mdn-content/files/en-us/web/api/usbconfiguration/configurationname/index.md | ---
title: "USBConfiguration: configurationName property"
short-title: configurationName
slug: Web/API/USBConfiguration/configurationName
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.USBConfiguration.configurationName
---
{{securecontext_header}}{{APIRef("WebUSB API")}}{{SeeCompatTable}}
The **`configurationName`** read-only property
of the {{domxref("USBConfiguration")}} interface returns the name provided by the device
to describe this configuration. This is equal to the value of the string descriptor with
the index provided in the [`iConfiguration`](https://www.beyondlogic.org/usbnutshell/usb5.shtml#ConfigurationDescriptors)
field of the configuration descriptor defining this configuration.
## Value
The name provided by the device to describe this configuration.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/usbconfiguration | data/mdn-content/files/en-us/web/api/usbconfiguration/usbconfiguration/index.md | ---
title: "USBConfiguration: USBConfiguration() constructor"
short-title: USBConfiguration()
slug: Web/API/USBConfiguration/USBConfiguration
page-type: web-api-constructor
status:
- experimental
browser-compat: api.USBConfiguration.USBConfiguration
---
{{securecontext_header}}{{APIRef("WebUSB API")}}{{SeeCompatTable}}
The **`USBConfiguration()`** constructor
creates a new {{domxref("USBConfiguration")}} object which contains information about
the configuration on the provided USBDevice with the given configuration value.
## Syntax
```js-nolint
new USBConfiguration(device, configurationValue)
```
### Parameters
- `device`
- : Specifies the {{domxref('USBDevice')}} you want to configure.
- `configurationValue`
- : Specifies the [configuration descriptor](https://www.beyondlogic.org/usbnutshell/usb5.shtml#ConfigurationDescriptors) you want to read. This is an unsigned integer in the range 0 to 255.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/usbconfiguration | data/mdn-content/files/en-us/web/api/usbconfiguration/interfaces/index.md | ---
title: "USBConfiguration: interfaces property"
short-title: interfaces
slug: Web/API/USBConfiguration/interfaces
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.USBConfiguration.interfaces
---
{{securecontext_header}}{{APIRef("WebUSB API")}}{{SeeCompatTable}}
The **`interfaces`** read-only property of the
{{domxref("USBConfiguration")}} interface returns an array containing instances of the
{{domxref('USBInterface')}} describing each interface supported by this configuration.
## Value
An array containing instances of {{domxref('USBInterface')}}.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/usbconfiguration | data/mdn-content/files/en-us/web/api/usbconfiguration/configurationvalue/index.md | ---
title: "USBConfiguration: configurationValue property"
short-title: configurationValue
slug: Web/API/USBConfiguration/configurationValue
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.USBConfiguration.configurationValue
---
{{securecontext_header}}{{APIRef("WebUSB API")}}{{SeeCompatTable}}
The **`configurationValue`** read-only property
of the {{domxref("USBConfiguration")}} interface returns the configuration value of this configuration. This is equal to the
[`bConfigurationValue`](https://www.beyondlogic.org/usbnutshell/usb5.shtml#ConfigurationDescriptors) field of the configuration descriptor provided by the device defining this configuration.
## Value
The [configuration descriptor](https://www.beyondlogic.org/usbnutshell/usb5.shtml#ConfigurationDescriptors) of the {{domxref("USBDevice")}} specified in the constructor of the
current {{domxref("USBConfiguration")}} instance.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/htmltrackelement/index.md | ---
title: HTMLTrackElement
slug: Web/API/HTMLTrackElement
page-type: web-api-interface
browser-compat: api.HTMLTrackElement
---
{{ APIRef("HTML DOM") }}
The **`HTMLTrackElement`** interface represents an {{Glossary("HTML")}} {{HTMLElement("track")}} element within the {{Glossary("DOM")}}. This element can be used as a child of either {{HTMLElement("audio")}} or {{HTMLElement("video")}} to specify a text track containing information such as closed captions or subtitles.
{{InheritanceDiagram}}
## Instance properties
_Inherits properties from its parent, {{domxref("HTMLElement")}}._
- {{domxref("HTMLTrackElement.kind")}}
- : A string that reflects the [`kind`](/en-US/docs/Web/HTML/Element/track#kind) HTML attribute, indicating how the text track is meant to be used. Possible values are: `subtitles`, `captions`, `descriptions`, `chapters`, or `metadata`.
- {{domxref("HTMLTrackElement.src")}}
- : A string that reflects the [`src`](/en-US/docs/Web/HTML/Element/track#src) HTML attribute, indicating the address of the text track data.
- {{domxref("HTMLTrackElement.srclang")}}
- : A string that reflects the [`srclang`](/en-US/docs/Web/HTML/Element/track#srclang) HTML attribute, indicating the language of the text track data.
- {{domxref("HTMLTrackElement.label")}}
- : A string that reflects the [`label`](/en-US/docs/Web/HTML/Element/track#label) HTML attribute, indicating a user-readable title for the track.
- {{domxref("HTMLTrackElement.default")}}
- : A boolean value reflecting the [`default`](/en-US/docs/Web/HTML/Element/track#default) attribute, indicating that the track is to be enabled if the user's preferences do not indicate that another track would be more appropriate.
- {{domxref("HTMLTrackElement.readyState")}} {{ReadOnlyInline}}
- : Returns an `unsigned short` that show the readiness state of the track:
| Constant | Value | Description |
| --------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `NONE` | 0 | Indicates that the text track's cues have not been obtained. |
| `LOADING` | 1 | Indicates that the text track is loading and there have been no fatal errors encountered so far. Further cues might still be added to the track by the parser. |
| `LOADED` | 2 | Indicates that the text track has been loaded with no fatal errors. |
| `ERROR` | 3 | Indicates that the text track was enabled, but when the user agent attempted to obtain it, this failed in some way. Some or all of the cues are likely missing and will not be obtained. |
- {{domxref("HTMLTrackElement.track")}} {{ReadOnlyInline}}
- : Returns {{Domxref("TextTrack")}} is the track element's text track data.
## Instance methods
_No specific method; inherits methods from its parent, {{domxref("HTMLElement")}}._
## Events
_Inherits events from its parent, {{domxref("HTMLElement")}}._
Listen to these events using {{domxref("EventTarget/addEventListener", "addEventListener()")}} or by assigning an event listener to the `oneventname` property of this interface:
- {{domxref("HTMLTrackElement.cuechange_event", "cuechange")}}
- : Sent when the underlying {{domxref("TextTrack")}} has changed the currently-presented cues. This event is always sent to the `TextTrack` but is _also_ sent to the `HTMLTrackElement` if one is associated with the track.
You may also use the `oncuechange` event handler to establish a handler for this event.
## Usage notes
### Loading of the track's text resource
The WebVTT or TTML data describing the actual cues for the text track isn't loaded if the track's {{domxref("TextTrack.mode", "mode")}} is initially in the `disabled` state. If you need to be able to perform any processing on the track after the `<track>` is set up, you should instead ensure that the track's `mode` is either `hidden` (if you don't want it to start out being presented to the user) or `showing` (to initially display the track). You can then change the mode as desired later.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- The HTML element implementing this interface: {{ HTMLElement("track") }}.
| 0 |
data/mdn-content/files/en-us/web/api/htmltrackelement | data/mdn-content/files/en-us/web/api/htmltrackelement/cuechange_event/index.md | ---
title: "HTMLTrackElement: cuechange event"
short-title: cuechange
slug: Web/API/HTMLTrackElement/cuechange_event
page-type: web-api-event
browser-compat: api.HTMLTrackElement.cuechange_event
---
{{APIRef("WebVTT")}}
The **`cuechange`** event fires when a {{domxref("TextTrack")}} has changed the currently displaying cues. The event is fired on both the `TextTrack` and the {{domxref("HTMLTrackElement")}} in which it's being presented, if any.
## Syntax
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.
```js
addEventListener("cuechange", (event) => {});
oncuechange = (event) => {};
```
## Event type
A generic {{DOMxRef("Event")}} with no added properties.
## Examples
The underlying {{domxref("TextTrack")}}, indicated by the {{domxref("HTMLTrackElement.track", "track")}} property, receives a `cuechange` event every time the currently-presented cue is changed. This happens even if the track isn't associated with a media element.
If the track _is_ associated with a media element, using the {{HTMLElement("track")}} element as a child of the {{HTMLElement("audio")}} or {{HTMLElement("video")}} element, the `cuechange` event is also sent to the {{domxref("HTMLTrackElement")}}.
```js
let textTrackElem = document.getElementById("texttrack");
textTrackElem.addEventListener("cuechange", (event) => {
let cues = event.target.track.activeCues;
});
```
Alternatively, you can use the `oncuechange` event handler:
```js
let textTrackElem = document.getElementById("texttrack");
textTrackElem.oncuechange = (event) => {
let cues = event.target.track.activeCues;
};
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{glossary("WebVTT")}}
- The same event on {{domxref("TextTrack")}}: {{domxref("TextTrack.cuechange_event", "cuechange")}}
| 0 |
data/mdn-content/files/en-us/web/api/htmltrackelement | data/mdn-content/files/en-us/web/api/htmltrackelement/src/index.md | ---
title: "HTMLTrackElement: src property"
short-title: src
slug: Web/API/HTMLTrackElement/src
page-type: web-api-instance-property
browser-compat: api.HTMLTrackElement.src
---
{{APIRef("HTML DOM")}}
The **`HTMLTrackElement.src`** property reflects the value of
the {{HTMLElement("track")}} element's [`src`](/en-US/docs/Web/HTML/Element/track#src) attribute, which
indicates the URL of the text track's data.
## Value
A string object containing the URL of the text track data.
## Example
```js
// coming soon
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("HTMLTrackElement")}}: Interface used to define the `HTMLTrackElement.src` property
- {{HTMLElement("track")}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/ui_events/index.md | ---
title: UI Events
slug: Web/API/UI_Events
page-type: web-api-overview
spec-urls: https://w3c.github.io/uievents/
---
{{DefaultAPISidebar("UI Events")}}
## Concepts and Usage
The UI Events API defines a system for handling user interactions such as mouse and keyboard input. This includes:
- events that are fired on specific user actions such keypresses or mouse clicks. Most of these events fire on the {{domxref("Element")}} interface, but the events relating to loading and unloading resources fire on the {{domxref("Window")}} interface.
- event interfaces, which are passed into handlers for these events. These interfaces inherit from {{domxref("Event")}} and provide extra information specific to the type of user interaction: for example, the {{domxref("KeyboardEvent")}} is passed into a {{domxref("Element.keydown_event", "keydown")}} event handler and provides information about the key that was pressed.
## Interfaces
- {{domxref("CompositionEvent")}}
- : Passed into handlers for composition events. Composition events enable a user to enter characters that might not be available on the physical keyboard.
- {{domxref("FocusEvent")}}
- : Passed into handlers for focus events, which are associated with elements receiving or losing focus.
- {{domxref("InputEvent")}}
- : Passed into handlers for input events, which are associated with the user entering some input; for example, using an {{HTMLElement("input")}} element.
- {{domxref("KeyboardEvent")}}
- : Passed into handlers for keyboard up/down events.
- {{domxref("MouseEvent")}}
- : Passed into event handlers for mouse events, including mouse move, mousing over and out, and mouse button up or down. Note that {{domxref("Element.auxclick_event", "auxclick")}}, {{domxref("Element.click_event", "click")}}, and {{domxref("Element.dblclick_event", "dblclick")}} events are passed {{domxref("PointerEvent")}} objects.
- {{domxref("MouseScrollEvent")}} {{deprecated_inline}}
- : Deprecated, Firefox-only, non-standard interface for scroll events. Use {{domxref("WheelEvent")}} instead.
- {{domxref("MutationEvent")}} {{deprecated_inline}}
- : Passed into mutation event handlers, which were designed to allow notifications of changes to the DOM. Now deprecated: use {{domxref("MutationObserver")}} instead.
- {{domxref("UIEvent")}}
- : A base from which other UI events inherit, and also the event interface passed into some events such as {{domxref("Window.load_event", "load")}} and {{domxref("Window.unload_event", "unload")}}.
- {{domxref("WheelEvent")}}
- : Passed into the handler for the {{domxref("Element.wheel_event", "wheel")}} event, which fires when the user rotates a mouse wheel or similar user interface component such as a touchpad.
## Events
- {{domxref("Window.abort_event", "abort")}}
- : Fired when loading a resource has been aborted (for example, because the user canceled it).
- {{domxref("Element.auxclick_event", "auxclick")}}
- : Fired when the user clicks the non-primary pointer button.
- {{domxref("Element.beforeinput_event", "beforeinput")}}
- : Fired just before the DOM is about to be updated with some user input.
- {{domxref("Element.blur_event", "blur")}}
- : Fired when an element has lost focus.
- {{domxref("Element.click_event", "click")}}
- : Fired when the user clicks the primary pointer button.
- {{domxref("Element.compositionend_event", "compositionend")}}
- : Fired when a text composition system (such as a speech-to-text processor) has finished its session; for example, because the user has closed it.
- {{domxref("Element.compositionstart_event", "compositionstart")}}
- : Fired when the user has started a new session with a text composition system.
- {{domxref("Element.compositionupdate_event", "compositionupdate")}}
- : Fired when a text composition system updates its text with a new character, reflected in an update to the `data` property of the {{domxref("CompositionEvent")}}.
- {{domxref("Element.contextmenu_event", "contextmenu")}}
- : Fired just before a context menu is invoked.
- {{domxref("Element.dblclick_event", "dblclick")}}
- : Fired when the user double-clicks the primary pointer button.
- {{domxref("HTMLElement/error_event", "error")}}
- : Fired when a resource fails to load or can't be processed (for example, if an image is invalid or a script has an error).
- {{domxref("Element.focus_event", "focus")}}
- : Fired when an element has received focus.
- {{domxref("Element.focusin_event", "focusin")}}
- : Fired when an element is just about to receive focus.
- {{domxref("Element.focusout_event", "focusout")}}
- : Fired when an element is just about to lose focus.
- {{domxref("Element.input_event", "input")}}
- : Fired just after the DOM has been updated with some user input (for example, some text input).
- {{domxref("Element.keydown_event", "keydown")}}
- : Fired when the user has pressed a key.
- {{domxref("Element.keypress_event", "keypress")}} {{deprecated_inline}}
- : Fired when the user has pressed a key, only if the key produces a character value. Use {{domxref("Element.keydown_event", "keydown")}} instead.
- {{domxref("Element.keyup_event", "keyup")}}
- : Fired when the user has released a key.
- {{domxref("Window.load_event", "load")}}
- : Fired when the whole page has loaded, including all dependent resources such as stylesheets and images.
- {{domxref("Element.mousedown_event", "mousedown")}}
- : Fired when the user presses a button on a mouse or other pointing device, while the pointer is over the element.
- {{domxref("Element.mouseenter_event", "mouseenter")}}
- : Fired when a mouse or other pointing device is moved inside the boundary of the element or one of its descendants.
- {{domxref("Element.mouseleave_event", "mouseleave")}}
- : Fired when a mouse or other pointing device is moved outside the boundary of the element and all of its descendants.
- {{domxref("Element.mousemove_event", "mousemove")}}
- : Fired when a mouse or other pointing device is moved while over an element.
- {{domxref("Element.mouseout_event", "mouseout")}}
- : Fired when a mouse or other pointing device is moved outside the boundary of the element.
- {{domxref("Element.mouseover_event", "mouseover")}}
- : Fired when a mouse or other pointing device is moved over an element.
- {{domxref("Element.mouseup_event", "mouseup")}}
- : Fired when the user releases a button on a mouse or other pointing device, while the pointer is over the element.
- {{domxref("Window.unload_event", "unload")}}
- : Fired when the document or a child resource are being unloaded.
- {{domxref("Element.wheel_event", "wheel")}}
- : Fired when the user rotates a mouse wheel or similar user interface component such as a touchpad.
## Examples
### Mouse events
This example logs mouse events along with the X and Y coordinates at which the event was generated. Try moving the mouse into the yellow and red squares, and clicking or double-clicking.
#### HTML
```html
<div id="outer">
<div id="inner"></div>
</div>
<div id="log">
<pre id="contents"></pre>
<button id="clear">Clear log</button>
</div>
```
#### CSS
```css
body {
display: flex;
gap: 1rem;
}
#outer {
height: 200px;
width: 200px;
display: flex;
justify-content: center;
align-items: center;
background-color: yellow;
}
#inner {
height: 100px;
width: 100px;
background-color: red;
}
#contents {
height: 150px;
width: 250px;
border: 1px solid black;
padding: 0.5rem;
overflow: scroll;
}
```
#### JavaScript
```js
const outer = document.querySelector("#outer");
const inner = document.querySelector("#inner");
const contents = document.querySelector("#contents");
const clear = document.querySelector("#clear");
let lines = 0;
outer.addEventListener("click", (event) => {
log(event);
});
outer.addEventListener("dblclick", (event) => {
log(event);
});
outer.addEventListener("mouseover", (event) => {
log(event);
});
outer.addEventListener("mouseout", (event) => {
log(event);
});
outer.addEventListener("mouseenter", (event) => {
log(event);
});
outer.addEventListener("mouseleave", (event) => {
log(event);
});
function log(event) {
const prefix = `${String(lines++).padStart(3, "0")}: `;
const line = `${event.type}(${event.clientX}, ${event.clientY})`;
contents.textContent = `${contents.textContent}${prefix}${line}\n`;
contents.scrollTop = contents.scrollHeight;
}
clear.addEventListener("click", () => {
contents.textContent = "";
lines = 0;
});
```
#### Result
{{EmbedLiveSample("Mouse events", 0, 250)}}
### Keyboard and input events
This example logs {{domxref("Element.keydown_event", "keydown")}}, {{domxref("Element.beforeinput_event", "beforeinput")}} and, {{domxref("Element.input_event", "input")}} events. Try typing into the text area. Note that keys like <kbd>Shift</kbd> produce `keydown` events but not `input` events.
#### HTML
```html
<textarea id="story" rows="5" cols="33"></textarea>
<div id="log">
<pre id="contents"></pre>
<button id="clear">Clear log</button>
</div>
```
#### CSS
```css
body {
display: flex;
gap: 1rem;
}
#story {
padding: 0.5rem;
}
#contents {
height: 150px;
width: 250px;
border: 1px solid black;
padding: 0.5rem;
overflow: scroll;
}
```
#### JavaScript
```js
const story = document.querySelector("#story");
const contents = document.querySelector("#contents");
const clear = document.querySelector("#clear");
let lines = 0;
story.addEventListener("keydown", (event) => {
log(`${event.type}(${event.key})`);
});
story.addEventListener("beforeinput", (event) => {
log(`${event.type}(${event.data})`);
});
story.addEventListener("input", (event) => {
log(`${event.type}(${event.data})`);
});
function log(line) {
const prefix = `${String(lines++).padStart(3, "0")}: `;
contents.textContent = `${contents.textContent}${prefix}${line}\n`;
contents.scrollTop = contents.scrollHeight;
}
clear.addEventListener("click", () => {
contents.textContent = "";
lines = 0;
});
```
#### Result
{{EmbedLiveSample("Keyboard and input events", 0, 250)}}
## Specifications
{{Specifications}}
## See also
- [Pointer Events API](/en-US/docs/Web/API/Pointer_events)
- [Touch Events](/en-US/docs/Web/API/Touch_events)
| 0 |
data/mdn-content/files/en-us/web/api/ui_events | data/mdn-content/files/en-us/web/api/ui_events/keyboard_event_code_values/index.md | ---
title: Code values for keyboard events
slug: Web/API/UI_Events/Keyboard_event_code_values
page-type: guide
---
{{DefaultAPISidebar("UI Events")}}
The following tables show what code values are used for each native scancode or virtual keycode on major platforms. The reason is that some browsers choose to interpret physical keys differently, there are some differences in which keys map to which codes. These tables show those variations when known.
## Code values on Windows
This table shows the Windows scan codes representing keys and the `KeyboardEvent.code` values which correspond to those hardware keys. Only keys which generate scan codes on Windows are listed.
In the cells, "(❌ Missing)" means that this code value cannot be detected on this browser;
"(⚠️ Not the same on xyz)" means that this string represents a different code value on the browser xyz and that special care has to be done
when using it.
<table class="standard-table">
<thead>
<tr>
<th scope="row"></th>
<th colspan="2" scope="col">
<strong><code>KeyboardEvent.code</code></strong> value
</th>
</tr>
<tr>
<th scope="row">Code</th>
<th scope="col">Firefox</th>
<th scope="col">Chrome</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><code>0x0000</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x0001</code></th>
<td><code>"Escape"</code></td>
<td><code>"Escape"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0002</code></th>
<td><code>"Digit1"</code></td>
<td><code>"Digit1"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0003</code></th>
<td><code>"Digit2"</code></td>
<td><code>"Digit2"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0004</code></th>
<td><code>"Digit3"</code></td>
<td><code>"Digit3"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0005</code></th>
<td><code>"Digit4"</code></td>
<td><code>"Digit4"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0006</code></th>
<td><code>"Digit5"</code></td>
<td><code>"Digit5"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0007</code></th>
<td><code>"Digit6"</code></td>
<td><code>"Digit6"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0008</code></th>
<td><code>"Digit7"</code></td>
<td><code>"Digit7"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0009</code></th>
<td><code>"Digit8"</code></td>
<td><code>"Digit8"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000A</code></th>
<td><code>"Digit9"</code></td>
<td><code>"Digit9"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000B</code></th>
<td><code>"Digit0"</code></td>
<td><code>"Digit0"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000C</code></th>
<td><code>"Minus"</code></td>
<td><code>"Minus"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000D</code></th>
<td><code>"Equal"</code></td>
<td><code>"Equal"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000E</code></th>
<td><code>"Backspace"</code></td>
<td><code>"Backspace"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000F</code></th>
<td><code>"Tab"</code></td>
<td><code>"Tab"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0010</code></th>
<td><code>"KeyQ"</code></td>
<td><code>"KeyQ"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0011</code></th>
<td><code>"KeyW"</code></td>
<td><code>"KeyW"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0012</code></th>
<td><code>"KeyE"</code></td>
<td><code>"KeyE"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0013</code></th>
<td><code>"KeyR"</code></td>
<td><code>"KeyR"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0014</code></th>
<td><code>"KeyT"</code></td>
<td><code>"KeyT"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0015</code></th>
<td><code>"KeyY"</code></td>
<td><code>"KeyY"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0016</code></th>
<td><code>"KeyU"</code></td>
<td><code>"KeyU"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0017</code></th>
<td><code>"KeyI"</code></td>
<td><code>"KeyI"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0018</code></th>
<td><code>"KeyO"</code></td>
<td><code>"KeyO"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0019</code></th>
<td><code>"KeyP"</code></td>
<td><code>"KeyP"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001A</code></th>
<td><code>"BracketLeft"</code></td>
<td><code>"BracketLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001B</code></th>
<td><code>"BracketRight"</code></td>
<td><code>"BracketRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001C</code></th>
<td><code>"Enter"</code></td>
<td><code>"Enter"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001D</code></th>
<td><code>"ControlLeft"</code></td>
<td><code>"ControlLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001E</code></th>
<td><code>"KeyA"</code></td>
<td><code>"KeyA"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001F</code></th>
<td><code>"KeyS"</code></td>
<td><code>"KeyS"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0020</code></th>
<td><code>"KeyD"</code></td>
<td><code>"KeyD"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0021</code></th>
<td><code>"KeyF"</code></td>
<td><code>"KeyF"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0022</code></th>
<td><code>"KeyG"</code></td>
<td><code>"KeyG"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0023</code></th>
<td><code>"KeyH"</code></td>
<td><code>"KeyH"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0024</code></th>
<td><code>"KeyJ"</code></td>
<td><code>"KeyJ"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0025</code></th>
<td><code>"KeyK"</code></td>
<td><code>"KeyK"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0026</code></th>
<td><code>"KeyL"</code></td>
<td><code>"KeyL"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0027</code></th>
<td><code>"Semicolon"</code></td>
<td><code>"Semicolon"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0028</code></th>
<td><code>"Quote"</code></td>
<td><code>"Quote"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0029</code></th>
<td><code>"Backquote"</code></td>
<td><code>"Backquote"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002A</code></th>
<td><code>"ShiftLeft"</code></td>
<td><code>"ShiftLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002B</code></th>
<td><code>"Backslash"</code></td>
<td><code>"Backslash"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002C</code></th>
<td><code>"KeyZ"</code></td>
<td><code>"KeyZ"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002D</code></th>
<td><code>"KeyX"</code></td>
<td><code>"KeyX"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002E</code></th>
<td><code>"KeyC"</code></td>
<td><code>"KeyC"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002F</code></th>
<td><code>"KeyV"</code></td>
<td><code>"KeyV"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0030</code></th>
<td><code>"KeyB"</code></td>
<td><code>"KeyB"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0031</code></th>
<td><code>"KeyN"</code></td>
<td><code>"KeyN"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0032</code></th>
<td><code>"KeyM"</code></td>
<td><code>"KeyM"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0033</code></th>
<td><code>"Comma"</code></td>
<td><code>"Comma"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0034</code></th>
<td><code>"Period"</code></td>
<td><code>"Period"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0035</code></th>
<td><code>"Slash"</code></td>
<td><code>"Slash"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0036</code></th>
<td><code>"ShiftRight"</code></td>
<td><code>"ShiftRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0037</code></th>
<td><code>"NumpadMultiply"</code></td>
<td><code>"NumpadMultiply"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0038</code></th>
<td><code>"AltLeft"</code></td>
<td><code>"AltLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0039</code></th>
<td><code>"Space"</code></td>
<td><code>"Space"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003A</code></th>
<td><code>"CapsLock"</code></td>
<td><code>"CapsLock"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003B</code></th>
<td><code>"F1"</code></td>
<td><code>"F1"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003C</code></th>
<td><code>"F2"</code></td>
<td><code>"F2"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003D</code></th>
<td><code>"F3"</code></td>
<td><code>"F3"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003E</code></th>
<td><code>"F4"</code></td>
<td><code>"F4"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003F</code></th>
<td><code>"F5"</code></td>
<td><code>"F5"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0040</code></th>
<td><code>"F6"</code></td>
<td><code>"F6"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0041</code></th>
<td><code>"F7"</code></td>
<td><code>"F7"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0042</code></th>
<td><code>"F8"</code></td>
<td><code>"F8"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0043</code></th>
<td><code>"F9"</code></td>
<td><code>"F9"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0044</code></th>
<td><code>"F10"</code></td>
<td><code>"F10"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0045</code></th>
<td><code>"Pause"</code></td>
<td><code>"Pause"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0046</code></th>
<td><code>"ScrollLock"</code></td>
<td><code>"ScrollLock"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0047</code></th>
<td><code>"Numpad7"</code></td>
<td><code>"Numpad7"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0048</code></th>
<td><code>"Numpad8"</code></td>
<td><code>"Numpad8"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0049</code></th>
<td><code>"Numpad9"</code></td>
<td><code>"Numpad9"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004A</code></th>
<td><code>"NumpadSubtract"</code></td>
<td><code>"NumpadSubtract"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004B</code></th>
<td><code>"Numpad4"</code></td>
<td><code>"Numpad4"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004C</code></th>
<td><code>"Numpad5"</code></td>
<td><code>"Numpad5"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004D</code></th>
<td><code>"Numpad6"</code></td>
<td><code>"Numpad6"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004E</code></th>
<td><code>"NumpadAdd"</code></td>
<td><code>"NumpadAdd"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004F</code></th>
<td><code>"Numpad1"</code></td>
<td><code>"Numpad1"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0050</code></th>
<td><code>"Numpad2"</code></td>
<td><code>"Numpad2"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0051</code></th>
<td><code>"Numpad3"</code></td>
<td><code>"Numpad3"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0052</code></th>
<td><code>"Numpad0"</code></td>
<td><code>"Numpad0"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0053</code></th>
<td><code>"NumpadDecimal"</code></td>
<td><code>"NumpadDecimal"</code></td>
</tr>
<tr>
<th scope="row">
<code>0x0054 (<kbd>Alt</kbd> + <kbd>PrintScreen</kbd>)</code>
</th>
<td><code>"PrintScreen"</code> (⚠️ Not the same on Chrome)</td>
<td><code>""</code> (❌ Missing)</td>
</tr>
<tr>
<th scope="row"><code>0x0055</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x0056</code></th>
<td><code>"IntlBackslash"</code></td>
<td><code>"IntlBackslash"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0057</code></th>
<td><code>"F11"</code></td>
<td><code>"F11"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0058</code></th>
<td><code>"F12"</code></td>
<td><code>"F12"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0059</code></th>
<td><code>"NumpadEqual"</code></td>
<td><code>"NumpadEqual"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x005A</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x005B</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code> (was <code>"F13"</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x005C</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code> (was <code>"F14"</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x005D</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code> (was <code>"F15"</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x005E</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x005F</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x0060</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x0061</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x0062</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x0063</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code> (was <code>"F16"</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x0064</code></th>
<td><code>"F13"</code></td>
<td><code>"F13"</code> (was <code>"F17"</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x0065</code></th>
<td><code>"F14"</code></td>
<td><code>"F14"</code> (was <code>"F18"</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x0066</code></th>
<td><code>"F15"</code></td>
<td><code>"F15"</code> (was <code>"F19"</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x0067</code></th>
<td><code>"F16"</code></td>
<td><code>"F16"</code> (was <code>"F20"</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x0068</code></th>
<td><code>"F17"</code></td>
<td><code>"F17"</code> (was <code>"F21"</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x0069</code></th>
<td><code>"F18"</code></td>
<td><code>"F18"</code> (was <code>"F22"</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x006A</code></th>
<td><code>"F19"</code></td>
<td><code>"F19"</code> (was <code>"F23"</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x006B</code></th>
<td><code>"F20"</code></td>
<td><code>"F20"</code> (was <code>"F24"</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x006C</code></th>
<td><code>"F21"</code></td>
<td><code>"F21"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x006D</code></th>
<td><code>"F22"</code></td>
<td><code>"F22"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x006E</code></th>
<td><code>"F23"</code></td>
<td><code>"F23"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x006F</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x0070</code></th>
<td><code>"KanaMode"</code></td>
<td><code>"KanaMode"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row">
<code>0x0071</code> (<kbd>Hanja</kbd> key without Korean keyboard
layout)
</th>
<td><code>"Lang2"</code></td>
<td><code>"Lang2"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row">
<code>0x0072</code> (<kbd>Han/Yeong</kbd> key without Korean keyboard
layout)
</th>
<td><code>"Lang1"</code></td>
<td><code>"Lang1"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x0073</code></th>
<td><code>"IntlRo"</code></td>
<td><code>"IntlRo"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x0074</code>, <code>0x0075</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x0076</code></th>
<td><code>"F24"</code></td>
<td><code>"F24"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x0077</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"Lang4"</code> (was <code>""</code> prior to Chrome 48) (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0x0078</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"Lang3"</code> (was <code>""</code> prior to Chrome 48) (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0x0079</code></th>
<td><code>"Convert"</code></td>
<td><code>"Convert"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x007A</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x007B</code></th>
<td><code>"NonConvert"</code></td>
<td><code>"NonConvert"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x007C</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x007D</code></th>
<td><code>"IntlYen"</code></td>
<td><code>"IntlYen"</code></td>
</tr>
<tr>
<th scope="row"><code>0x007E</code></th>
<td><code>"NumpadComma"</code></td>
<td><code>"NumpadComma"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0x007F</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE000</code> ~ <code>0xE007</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE008</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"Undo"</code> (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0xE009</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE00A</code></th>
<td><code>""</code> (❌ Missing)</td>
<td><code>"Paste"</code> (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0xE00B</code> ~ <code>0xE00F</code></th>
<td>""</td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE010</code></th>
<td><code>"MediaTrackPrevious"</code></td>
<td><code>"MediaTrackPrevious"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE011</code> ~ <code>0xE016</code></th>
<td><code>""</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE017</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"Cut"</code> (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0xE018</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"Copy"</code> (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0xE019</code></th>
<td><code>"MediaTrackNext"</code></td>
<td><code>"MediaTrackNext"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE01A, 0xE01B</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE01C</code></th>
<td><code>"NumpadEnter"</code></td>
<td><code>"NumpadEnter"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE01D</code></th>
<td><code>"ControlRight"</code></td>
<td><code>"ControlRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE01E</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code> (was <code>"LaunchMail"</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0xE01F</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE020</code></th>
<td><code>"AudioVolumeMute"</code></td>
<td><code>"AudioVolumeMute"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE021</code></th>
<td><code>"LaunchApp2"</code></td>
<td><code>"LaunchApp2"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0xE022</code></th>
<td><code>"MediaPlayPause"</code></td>
<td><code>"MediaPlayPause"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE023</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE024</code></th>
<td><code>"MediaStop"</code></td>
<td><code>"MediaStop"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE025</code> ~ <code>0xE02B</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE02C</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"Eject"</code> (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0xE02D</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE02E</code></th>
<td><code>"VolumeDown"</code> (⚠️ Not the same on Chrome)</td>
<td>
<code>"AudioVolumeDown"</code> (was <code>"VolumeDown"</code> prior to
Chrome 52) (⚠️ Not the same on Firefox)
</td>
</tr>
<tr>
<th scope="row"><code>0xE02F</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE030</code></th>
<td><code>"VolumeUp"</code> (⚠️ Not the same on Chrome)</td>
<td>
<code>"AudioVolumeUp"</code> (was <code>"VolumeUp"</code> prior to Chrome
52) (⚠️ Not the same on Firefox)
</td>
</tr>
<tr>
<th scope="row"><code>0xE031</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE032</code></th>
<td><code>"BrowserHome"</code></td>
<td><code>"BrowserHome"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE033</code>, <code>0xE034</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE035</code></th>
<td><code>"NumpadDivide"</code></td>
<td><code>"NumpadDivide"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE036</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE037</code></th>
<td><code>"PrintScreen"</code></td>
<td><code>"PrintScreen"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE038</code></th>
<td><code>"AltRight"</code></td>
<td><code>"AltRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE039</code>, <code>0xE03A</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE03B</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"Help"</code> (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0xE03C</code>~ <code>0xE044</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE045</code></th>
<td><code>"NumLock"</code></td>
<td><code>"NumLock"</code></td>
</tr>
<tr>
<th scope="row">
<code>0xE046</code> (<kbd>Ctrl</kbd> + <kbd>Pause</kbd>)
</th>
<td><code>"Pause"</code></td>
<td><code>"Pause"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE047</code></th>
<td><code>"Home"</code></td>
<td><code>"Home"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE048</code></th>
<td><code>"ArrowUp"</code></td>
<td><code>"ArrowUp"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE049</code></th>
<td><code>"PageUp"</code></td>
<td><code>"PageUp"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE04A</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE04B</code></th>
<td><code>"ArrowLeft"</code></td>
<td><code>"ArrowLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE04C</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE04D</code></th>
<td><code>"ArrowRight"</code></td>
<td><code>"ArrowRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE04E</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE04F</code></th>
<td><code>"End"</code></td>
<td><code>"End"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE050</code></th>
<td><code>"ArrowDown"</code></td>
<td><code>"ArrowDown"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE051</code></th>
<td><code>"PageDown"</code></td>
<td><code>"PageDown"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE052</code></th>
<td><code>"Insert"</code></td>
<td><code>"Insert"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE053</code></th>
<td><code>"Delete"</code></td>
<td><code>"Delete"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE054</code> ~ <code>0xE05A</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE05B</code></th>
<td><code>"MetaLeft"</code> (was <code>"OSLeft"</code> prior to Firefox 118)</td>
<td><code>"MetaLeft"</code> (was <code>"OSLeft"</code> prior to Chrome 52)</td>
</tr>
<tr>
<th scope="row"><code>0xE05C</code></th>
<td><code>"MetaRight"</code> (was <code>"OSRight"</code> prior to Firefox 118)</td>
<td><code>"MetaRight"</code> (was <code>"OSRight"</code> prior to Chrome 52)</td>
</tr>
<tr>
<th scope="row"><code>0xE05D</code></th>
<td><code>"ContextMenu"</code></td>
<td><code>"ContextMenu"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE05E</code></th>
<td><code>"Power"</code></td>
<td><code>"Power"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0xE05F</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"Sleep"</code> (was <code>""</code> prior to Chrome 48) (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0xE060</code> ~ <code>0xE062</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE063</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"WakeUp"</code> (was <code>""</code> prior to Chrome 48) (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0xE064</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0xE065</code></th>
<td><code>"BrowserSearch"</code></td>
<td><code>"BrowserSearch"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE066</code></th>
<td><code>"BrowserFavorites"</code></td>
<td><code>"BrowserFavorites"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE067</code></th>
<td><code>"BrowserRefresh"</code></td>
<td><code>"BrowserRefresh"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE068</code></th>
<td><code>"BrowserStop"</code></td>
<td><code>"BrowserStop"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE069</code></th>
<td><code>"BrowserForward"</code></td>
<td><code>"BrowserForward"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE06A</code></th>
<td><code>"BrowserBack"</code></td>
<td><code>"BrowserBack"</code></td>
</tr>
<tr>
<th scope="row"><code>0xE06B</code></th>
<td><code>"LaunchApp1"</code></td>
<td><code>"LaunchApp1"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0xE06C</code></th>
<td><code>"LaunchMail"</code></td>
<td><code>"LaunchMail"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0xE06D</code></th>
<td><code>"MediaSelect"</code></td>
<td><code>"MediaSelect"</code> (was <code>""</code> prior to Chrome 48)</td>
</tr>
<tr>
<th scope="row"><code>0xE06E ~ 0xE0F0</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row">
<code>0xE0F1</code> (<kbd>Hanja</kbd> key with Korean keyboard layout)
</th>
<td><code>"Lang2"</code> (⚠️ Not the same on Chrome)</td>
<td><code>""</code> (❌ Missing)</td>
</tr>
<tr>
<th scope="row">
<code>0xE0F2</code> (<kbd>Han/Yeong</kbd> key with Korean keyboard
layout)
</th>
<td><code>"Lang1"</code> (⚠️ Not the same on Chrome)</td>
<td><code>""</code> (❌ Missing)</td>
</tr>
</tbody>
</table>
## Code values on Mac
On macOS, it's hard to get scancode or something which can distinguish a physical key from a key event.
Therefore, Firefox always maps `code` value from the virtual keycode.
In the cells,
- "(❌ Missing)" means that this code value cannot be detected on this browser;
- "(⚠️ Not the same on xyz)" means that this string represents a different code value on the browser xyz and that special care has to be done
when using it;
- "(⚠️ Same string for `0xab`)" means that you cannot distinguished this key with the one matching `0xab`;
- "(⚠️ No events fired actually)" means that even if technically you have a specific string for this code, no event will be dispatched;
<table class="standard-table">
<thead>
<tr>
<th scope="row">Virtual keycode</th>
<th scope="col">Firefox</th>
<th scope="col">Chromium</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><code>kVK_ANSI_A (0x00)</code></th>
<td><code>"KeyA"</code></td>
<td><code>"KeyA"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_S (0x01)</code></th>
<td><code>"KeyS"</code></td>
<td><code>"KeyS"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_D (0x02)</code></th>
<td><code>"KeyD"</code></td>
<td><code>"KeyD"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_F (0x03)</code></th>
<td><code>"KeyF"</code></td>
<td><code>"KeyF"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_H (0x04)</code></th>
<td><code>"KeyH"</code></td>
<td><code>"KeyH"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_G (0x05)</code></th>
<td><code>"KeyG"</code></td>
<td><code>"KeyG"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Z (0x06)</code></th>
<td><code>"KeyZ"</code></td>
<td><code>"KeyZ"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_X (0x07)</code></th>
<td><code>"KeyX"</code></td>
<td><code>"KeyX"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_C (0x08)</code></th>
<td><code>"KeyC"</code></td>
<td><code>"KeyC"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_V (0x09)</code></th>
<td><code>"KeyV"</code></td>
<td><code>"KeyV"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ISO_Section (0x0A)</code></th>
<td><code>"IntlBackslash"</code></td>
<td><code>"IntlBackslash"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_B (0x0B)</code></th>
<td><code>"KeyB"</code></td>
<td><code>"KeyB"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Q (0x0C)</code></th>
<td><code>"KeyQ"</code></td>
<td><code>"KeyQ"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_W (0x0D)</code></th>
<td><code>"KeyW"</code></td>
<td><code>"KeyW"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_E (0x0E)</code></th>
<td><code>"KeyE"</code></td>
<td><code>"KeyE"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_R (0x0F)</code></th>
<td><code>"KeyR"</code></td>
<td><code>"KeyR"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Y (0x10)</code></th>
<td><code>"KeyY"</code></td>
<td><code>"KeyY"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_T (0x11)</code></th>
<td><code>"KeyT"</code></td>
<td><code>"KeyT"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_1 (0x12)</code></th>
<td><code>"Digit1"</code></td>
<td><code>"Digit1"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_2 (0x13)</code></th>
<td><code>"Digit2"</code></td>
<td><code>"Digit2"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_3 (0x14)</code></th>
<td><code>"Digit3"</code></td>
<td><code>"Digit3"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_4 (0x15)</code></th>
<td><code>"Digit4"</code></td>
<td><code>"Digit4"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_6 (0x16)</code></th>
<td><code>"Digit6"</code></td>
<td><code>"Digit6"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_5 (0x17)</code></th>
<td><code>"Digit5"</code></td>
<td><code>"Digit5"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Equal (0x18)</code></th>
<td><code>"Equal"</code></td>
<td><code>"Equal"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_9 (0x19)</code></th>
<td><code>"Digit9"</code></td>
<td><code>"Digit9"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_7 (0x1A)</code></th>
<td><code>"Digit7"</code></td>
<td><code>"Digit7"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Minus (0x1B)</code></th>
<td><code>"Minus"</code></td>
<td><code>"Minus"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_8 (0x1C)</code></th>
<td><code>"Digit8"</code></td>
<td><code>"Digit8"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_0 (0x1D)</code></th>
<td><code>"Digit0"</code></td>
<td><code>"Digit0"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_RightBracket (0x1E)</code></th>
<td><code>"BracketRight"</code></td>
<td><code>"BracketRight"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_O (0x1F)</code></th>
<td><code>"KeyO"</code></td>
<td><code>"KeyO"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_U (0x20)</code></th>
<td><code>"KeyU"</code></td>
<td><code>"KeyU"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_LeftBracket (0x21)</code></th>
<td><code>"BracketLeft"</code></td>
<td><code>"BracketLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_I (0x22)</code></th>
<td><code>"KeyI"</code></td>
<td><code>"KeyI"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_P (0x23)</code></th>
<td><code>"KeyP"</code></td>
<td><code>"KeyP"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_Return (0x24)</code></th>
<td><code>"Enter"</code></td>
<td><code>"Enter"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_L (0x25)</code></th>
<td><code>"KeyL"</code></td>
<td><code>"KeyL"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_J (0x26)</code></th>
<td><code>"KeyJ"</code></td>
<td><code>"KeyJ"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Quote (0x27)</code></th>
<td><code>"Quote"</code></td>
<td><code>"Quote"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_K (0x28)</code></th>
<td><code>"KeyK"</code></td>
<td><code>"KeyK"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Semicolon (0x29)</code></th>
<td><code>"Semicolon"</code></td>
<td><code>"Semicolon"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Backslash (0x2A)</code></th>
<td><code>"Backslash"</code></td>
<td><code>"Backslash"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Comma (0x2B)</code></th>
<td><code>"Comma"</code></td>
<td><code>"Comma"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Slash (0x2C)</code></th>
<td><code>"Slash"</code></td>
<td><code>"Slash"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_N (0x2D)</code></th>
<td><code>"KeyN"</code></td>
<td><code>"KeyN"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_M (0x2E)</code></th>
<td><code>"KeyM"</code></td>
<td><code>"KeyM"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Period (0x2F)</code></th>
<td><code>"Period"</code></td>
<td><code>"Period"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_Tab (0x30)</code></th>
<td><code>"Tab"</code></td>
<td><code>"Tab"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_Space (0x31)</code></th>
<td><code>"Space"</code></td>
<td><code>"Space"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Grave (0x32)</code></th>
<td><code>"Backquote"</code></td>
<td><code>"Backquote"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_Delete (0x33)</code></th>
<td><code>"Backspace"</code></td>
<td><code>"Backspace"</code></td>
</tr>
<tr>
<th scope="row">Enter key on keypad of PowerBook (<code>0x34</code>)</th>
<td><code>"NumpadEnter"</code>(⚠️ Same string for <code>0x4C</code>) (⚠️ Not the same on Chromium)</td>
<td><code>""</code> (❌ Missing)</td>
</tr>
<tr>
<th scope="row"><code>kVK_Escape (0x35)</code></th>
<td><code>"Escape"</code></td>
<td><code>"Escape"</code></td>
</tr>
<tr>
<th scope="row">right-command key (<code>0x36</code>)</th>
<td><code>"MetaRight"</code> (was <code>"OSRight"</code> prior to Firefox 118)</td>
<td><code>"MetaRight"</code> (was <code>"OSRight"</code> prior to Chromium 52)</td>
</tr>
<tr>
<th scope="row"><code>kVK_Command (0x37)</code></th>
<td><code>"MetaLeft"</code> (was <code>"OSLeft"</code> prior to Firefox 118)</td>
<td><code>"MetaLeft"</code> (was <code>"OSLeft"</code> prior to Chromium 52)</td>
</tr>
<tr>
<th scope="row"><code>kVK_Shift (0x38)</code></th>
<td><code>"ShiftLeft"</code></td>
<td><code>"ShiftLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_CapsLock (0x39)</code></th>
<td><code>"CapsLock"</code></td>
<td><code>"CapsLock"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_Option (0x3A)</code></th>
<td><code>"AltLeft"</code></td>
<td><code>"AltLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_Control (0x3B)</code></th>
<td><code>"ControlLeft"</code></td>
<td><code>"ControlLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_RightShift (0x3C)</code></th>
<td><code>"ShiftRight"</code></td>
<td><code>"ShiftRight"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_RightOption (0x3D)</code></th>
<td><code>"AltRight"</code></td>
<td><code>"AltRight"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_RightControl (0x3E)</code></th>
<td><code>"ControlRight"</code></td>
<td><code>"ControlRight"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_Function (0x3F)</code></th>
<td><code>"Fn"</code> (⚠️ No events fired actually)</td>
<td><code>""</code> (❌ Missing) (⚠️ No events fired actually)</td>
</tr>
<tr>
<th scope="row"><code>kVK_F17 (0x40)</code></th>
<td><code>"F17"</code></td>
<td><code>"F17"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_KeypadDecimal (0x41)</code></th>
<td><code>"NumpadDecimal"</code></td>
<td><code>"NumpadDecimal"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_KeypadMultiply (0x43)</code></th>
<td><code>"NumpadMultiply"</code></td>
<td><code>"NumpadMultiply"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_KeypadPlus (0x45)</code></th>
<td><code>"NumpadAdd"</code></td>
<td><code>"NumpadAdd"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_KeypadClear (0x47)</code></th>
<td><code>"NumLock"</code></td>
<td><code>"NumLock"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_VolumeUp (0x48)</code></th>
<td><code>"VolumeUp"</code> (⚠️ Not the same on Chromium)</td>
<td>
<code>"AudioVolumeUp" </code>(was <code>"VolumeUp"</code> prior to Chromium
1) (⚠️ Not the same on Firefox)
</td>
</tr>
<tr>
<th scope="row"><code>kVK_VolumeDown (0x49)</code></th>
<td><code>"VolumeDown"</code> (⚠️ Not the same on Chromium)</td>
<td>
<code>"AudioVolumeDown"</code> (was <code>"VolumeDown"</code> prior to
Chromium 52) (⚠️ Not the same on Firefox)
</td>
</tr>
<tr>
<th scope="row"><code>kVK_Mute (0x4A)</code></th>
<td><code>"VolumeMute"</code> (⚠️ Not the same on Chromium)</td>
<td>
<code>"AudioVolumeMute"</code> (was <code>"VolumeMute"</code> prior to
Chromium 52) (⚠️ Not the same on Firefox)
</td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_KeypadDivide (0x4B)</code></th>
<td><code>"NumpadDivide"</code></td>
<td><code>"NumpadDivide"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_KeypadEnter (0x4C)</code></th>
<td><code>"NumpadEnter"</code></td>
<td><code>"NumpadEnter"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_KeypadMinus (0x4E)</code></th>
<td><code>"NumpadSubtract"</code></td>
<td><code>"NumpadSubtract"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F18 (0x4F)</code></th>
<td><code>"F18"</code></td>
<td><code>"F18"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F19 (0x50)</code></th>
<td><code>"F19"</code></td>
<td><code>"F19"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_KeypadEquals (0x51)</code></th>
<td><code>"NumpadEqual"</code></td>
<td><code>"NumpadEqual"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Keypad0 (0x52)</code></th>
<td><code>"Numpad0"</code></td>
<td><code>"Numpad0"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Keypad1 (0x53)</code></th>
<td><code>"Numpad1"</code></td>
<td><code>"Numpad1"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Keypad2 (0x54)</code></th>
<td><code>"Numpad2"</code></td>
<td><code>"Numpad2"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Keypad3 (0x55)</code></th>
<td><code>"Numpad3"</code></td>
<td><code>"Numpad3"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Keypad4 (0x56)</code></th>
<td><code>"Numpad4"</code></td>
<td><code>"Numpad4"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Keypad5 (0x57)</code></th>
<td><code>"Numpad5"</code></td>
<td><code>"Numpad5"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Keypad6 (0x58)</code></th>
<td><code>"Numpad6"</code></td>
<td><code>"Numpad6"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Keypad7 (0x59)</code></th>
<td><code>"Numpad7"</code></td>
<td><code>"Numpad7"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F20 (0x5A)</code></th>
<td><code>"F20"</code></td>
<td><code>"F20"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Keypad8 (0x5B)</code></th>
<td><code>"Numpad8"</code></td>
<td><code>"Numpad8"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ANSI_Keypad9 (0x5C)</code></th>
<td><code>"Numpad9"</code></td>
<td><code>"Numpad9"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_JIS_Yen (0x5D)</code></th>
<td><code>"IntlYen"</code></td>
<td><code>"IntlYen"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_JIS_Underscore (0x5E)</code></th>
<td><code>"IntlRo"</code></td>
<td><code>"IntlRo"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_JIS_KeypadComma (0x5F)</code></th>
<td><code>"NumpadComma"</code></td>
<td><code>"NumpadComma"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F5 (0x60)</code></th>
<td><code>"F5"</code></td>
<td><code>"F5"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F6 (0x61)</code></th>
<td><code>"F6"</code></td>
<td><code>"F6"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F7 (0x62)</code></th>
<td><code>"F7"</code></td>
<td><code>"F7"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F3 (0x63)</code></th>
<td><code>"F3"</code></td>
<td><code>"F3"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F8 (0x64)</code></th>
<td><code>"F8"</code></td>
<td><code>"F8"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F9 (0x65)</code></th>
<td><code>"F9"</code></td>
<td><code>"F9"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_JIS_Eisu (0x66)</code></th>
<td><code>"Lang2"</code></td>
<td><code>"Lang2"</code> (was <code>""</code> prior to Chromium 82) (⚠️ No events fired actually)</td>
</tr>
<tr>
<th scope="row"><code>kVK_F11 (0x67)</code></th>
<td><code>"F11"</code></td>
<td><code>"F11"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_JIS_Kana (0x68)</code></th>
<td><code>"Lang1"</code></td>
<td><code>"Lang1"</code> (was <code>"KanaMode"</code> prior to Chromium 82) (⚠️ No events fired actually)</td>
</tr>
<tr>
<th scope="row"><code>kVK_F13 (0x69)</code></th>
<td><code>"F13"</code></td>
<td><code>"F13"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F16 (0x6A)</code></th>
<td><code>"F16"</code></td>
<td><code>"F16"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F14 (0x6B)</code></th>
<td><code>"F14"</code></td>
<td><code>"F14"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F10 (0x6D)</code></th>
<td><code>"F10"</code></td>
<td><code>"F10"</code></td>
</tr>
<tr>
<th scope="row">context menu key (<code>0x6E</code>)</th>
<td><code>"ContextMenu"</code></td>
<td><code>"ContextMenu"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F12 (0x6F)</code></th>
<td><code>"F12"</code></td>
<td><code>"F12"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F15 (0x71)</code></th>
<td><code>"F15"</code></td>
<td><code>"F15"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_Help (0x72)</code></th>
<td><code>"Help"</code> (⚠️ Not the same on Chromium)</td>
<td><code>"Insert"</code> (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>kVK_Home (0x73)</code></th>
<td><code>"Home"</code></td>
<td><code>"Home"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_PageUp (0x74)</code></th>
<td><code>"PageUp"</code></td>
<td><code>"PageUp"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_ForwardDelete (0x75)</code></th>
<td><code>"Delete"</code></td>
<td><code>"Delete"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F4 (0x76)</code></th>
<td><code>"F4"</code></td>
<td><code>"F4"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_End (0x77)</code></th>
<td><code>"End"</code></td>
<td><code>"End"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F2 (0x78)</code></th>
<td><code>"F2"</code></td>
<td><code>"F2"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_PageDown (0x79)</code></th>
<td><code>"PageDown"</code></td>
<td><code>"PageDown"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_F1 (0x7A)</code></th>
<td><code>"F1"</code></td>
<td><code>"F1"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_LeftArrow (0x7B)</code></th>
<td><code>"ArrowLeft"</code></td>
<td><code>"ArrowLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_RightArrow (0x7C)</code></th>
<td><code>"ArrowRight"</code></td>
<td><code>"ArrowRight"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_DownArrow (0x7D)</code></th>
<td><code>"ArrowDown"</code></td>
<td><code>"ArrowDown"</code></td>
</tr>
<tr>
<th scope="row"><code>kVK_UpArrow (0x7E)</code></th>
<td><code>"ArrowUp"</code></td>
<td><code>"ArrowUp"</code></td>
</tr>
</tbody>
</table>
## Code values on Linux (X11)
Note that X has too many keys and some of them are not testable with usual keyboard. So, following table is created from source code which maps from scancode to code value.
In the cells, "(❌ Missing)" means that this code value cannot be detected on this browser.
<table class="standard-table">
<thead>
<tr>
<th scope="row">scancode (hardware_keycode)</th>
<th scope="col">Firefox</th>
<th scope="col">Chromium</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><code>0x0009</code></th>
<td><code>"Escape"</code></td>
<td><code>"Escape"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000A</code></th>
<td><code>"Digit1"</code></td>
<td><code>"Digit1"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000B</code></th>
<td><code>"Digit2"</code></td>
<td><code>"Digit2"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000C</code></th>
<td><code>"Digit3"</code></td>
<td><code>"Digit3"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000D</code></th>
<td><code>"Digit4"</code></td>
<td><code>"Digit4"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000E</code></th>
<td><code>"Digit5"</code></td>
<td><code>"Digit5"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000F</code></th>
<td><code>"Digit6"</code></td>
<td><code>"Digit6"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0010</code></th>
<td><code>"Digit7"</code></td>
<td><code>"Digit7"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0011</code></th>
<td><code>"Digit8"</code></td>
<td><code>"Digit8"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0012</code></th>
<td><code>"Digit9"</code></td>
<td><code>"Digit9"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0013</code></th>
<td><code>"Digit0"</code></td>
<td><code>"Digit0"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0014</code></th>
<td><code>"Minus"</code></td>
<td><code>"Minus"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0015</code></th>
<td><code>"Equal"</code></td>
<td><code>"Equal"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0016</code></th>
<td><code>"Backspace"</code></td>
<td><code>"Backspace"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0017</code></th>
<td><code>"Tab"</code></td>
<td><code>"Tab"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0018</code></th>
<td><code>"KeyQ"</code></td>
<td><code>"KeyQ"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0019</code></th>
<td><code>"KeyW"</code></td>
<td><code>"KeyW"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001A</code></th>
<td><code>"KeyE"</code></td>
<td><code>"KeyE"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001B</code></th>
<td><code>"KeyR"</code></td>
<td><code>"KeyR"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001C</code></th>
<td><code>"KeyT"</code></td>
<td><code>"KeyT"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001D</code></th>
<td><code>"KeyY"</code></td>
<td><code>"KeyY"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001E</code></th>
<td><code>"KeyU"</code></td>
<td><code>"KeyU"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001F</code></th>
<td><code>"KeyI"</code></td>
<td><code>"KeyI"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0020</code></th>
<td><code>"KeyO"</code></td>
<td><code>"KeyO"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0021</code></th>
<td><code>"KeyP"</code></td>
<td><code>"KeyP"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0022</code></th>
<td><code>"BracketLeft"</code></td>
<td><code>"BracketLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0023</code></th>
<td><code>"BracketRight"</code></td>
<td><code>"BracketRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0024</code></th>
<td><code>"Enter"</code></td>
<td><code>"Enter"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0025</code></th>
<td><code>"ControlLeft"</code></td>
<td><code>"ControlLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0026</code></th>
<td><code>"KeyA"</code></td>
<td><code>"KeyA"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0027</code></th>
<td><code>"KeyS"</code></td>
<td><code>"KeyS"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0028</code></th>
<td><code>"KeyD"</code></td>
<td><code>"KeyD"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0029</code></th>
<td><code>"KeyF"</code></td>
<td><code>"KeyF"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002A</code></th>
<td><code>"KeyG"</code></td>
<td><code>"KeyG"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002B</code></th>
<td><code>"KeyH"</code></td>
<td><code>"KeyH"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002C</code></th>
<td><code>"KeyJ"</code></td>
<td><code>"KeyJ"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002D</code></th>
<td><code>"KeyK"</code></td>
<td><code>"KeyK"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002E</code></th>
<td><code>"KeyL"</code></td>
<td><code>"KeyL"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002F</code></th>
<td><code>"Semicolon"</code></td>
<td><code>"Semicolon"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0030</code></th>
<td><code>"Quote"</code></td>
<td><code>"Quote"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0031</code></th>
<td><code>"Backquote"</code></td>
<td><code>"Backquote"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0032</code></th>
<td><code>"ShiftLeft"</code></td>
<td><code>"ShiftLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0033</code></th>
<td><code>"Backslash"</code></td>
<td><code>"Backslash"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0034</code></th>
<td><code>"KeyZ"</code></td>
<td><code>"KeyZ"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0035</code></th>
<td><code>"KeyX"</code></td>
<td><code>"KeyX"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0036</code></th>
<td><code>"KeyC"</code></td>
<td><code>"KeyC"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0037</code></th>
<td><code>"KeyV"</code></td>
<td><code>"KeyV"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0038</code></th>
<td><code>"KeyB"</code></td>
<td><code>"KeyB"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0039</code></th>
<td><code>"KeyN"</code></td>
<td><code>"KeyN"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003A</code></th>
<td><code>"KeyM"</code></td>
<td><code>"KeyM"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003B</code></th>
<td><code>"Comma"</code></td>
<td><code>"Comma"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003C</code></th>
<td><code>"Period"</code></td>
<td><code>"Period"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003D</code></th>
<td><code>"Slash"</code></td>
<td><code>"Slash"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003E</code></th>
<td><code>"ShiftRight"</code></td>
<td><code>"ShiftRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003F</code></th>
<td><code>"NumpadMultiply"</code></td>
<td><code>"NumpadMultiply"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0040</code></th>
<td><code>"AltLeft"</code></td>
<td><code>"AltLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0041</code></th>
<td><code>"Space"</code></td>
<td><code>"Space"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0042</code></th>
<td><code>"CapsLock"</code></td>
<td><code>"CapsLock"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0043</code></th>
<td><code>"F1"</code></td>
<td><code>"F1"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0044</code></th>
<td><code>"F2"</code></td>
<td><code>"F2"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0045</code></th>
<td><code>"F3"</code></td>
<td><code>"F3"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0046</code></th>
<td><code>"F4"</code></td>
<td><code>"F4"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0047</code></th>
<td><code>"F5"</code></td>
<td><code>"F5"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0048</code></th>
<td><code>"F6"</code></td>
<td><code>"F6"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0049</code></th>
<td><code>"F7"</code></td>
<td><code>"F7"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004A</code></th>
<td><code>"F8"</code></td>
<td><code>"F8"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004B</code></th>
<td><code>"F9"</code></td>
<td><code>"F9"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004C</code></th>
<td><code>"F10"</code></td>
<td><code>"F10"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004D</code></th>
<td><code>"NumLock"</code></td>
<td><code>"NumLock"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004E</code></th>
<td><code>"ScrollLock"</code></td>
<td><code>"ScrollLock"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004F</code></th>
<td><code>"Numpad7"</code></td>
<td><code>"Numpad7"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0050</code></th>
<td><code>"Numpad8"</code></td>
<td><code>"Numpad8"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0051</code></th>
<td><code>"Numpad9"</code></td>
<td><code>"Numpad9"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0052</code></th>
<td><code>"NumpadSubtract"</code></td>
<td><code>"NumpadSubtract"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0053</code></th>
<td><code>"Numpad4"</code></td>
<td><code>"Numpad4"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0054</code></th>
<td><code>"Numpad5"</code></td>
<td><code>"Numpad5"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0055</code></th>
<td><code>"Numpad6"</code></td>
<td><code>"Numpad6"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0056</code></th>
<td><code>"NumpadAdd"</code></td>
<td><code>"NumpadAdd"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0057</code></th>
<td><code>"Numpad1"</code></td>
<td><code>"Numpad1"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0058</code></th>
<td><code>"Numpad2"</code></td>
<td><code>"Numpad2"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0059</code></th>
<td><code>"Numpad3"</code></td>
<td><code>"Numpad3"</code></td>
</tr>
<tr>
<th scope="row"><code>0x005A</code></th>
<td><code>"Numpad0"</code></td>
<td><code>"Numpad0"</code></td>
</tr>
<tr>
<th scope="row"><code>0x005B</code></th>
<td><code>"NumpadDecimal"</code></td>
<td><code>"NumpadDecimal"</code></td>
</tr>
<tr>
<th scope="row"><code>0x005C</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x005D</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"Lang5"</code> (was <code>""</code> prior to Chromium 48) (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0x005E</code></th>
<td><code>"IntlBackslash"</code></td>
<td><code>"IntlBackslash"</code></td>
</tr>
<tr>
<th scope="row"><code>0x005F</code></th>
<td><code>"F11"</code></td>
<td><code>"F11"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0060</code></th>
<td><code>"F12"</code></td>
<td><code>"F12"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0061</code></th>
<td><code>"IntlRo"</code></td>
<td><code>"IntlRo"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0062</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"Lang3"</code> (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0x0063</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"Lang4"</code> (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0x0064</code></th>
<td><code>"Convert"</code></td>
<td><code>"Convert"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0065</code></th>
<td><code>"KanaMode"</code></td>
<td><code>"KanaMode"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0066</code></th>
<td><code>"NonConvert"</code></td>
<td><code>"NonConvert"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0067</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x0068</code></th>
<td><code>"NumpadEnter"</code></td>
<td><code>"NumpadEnter"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0069</code></th>
<td><code>"ControlRight"</code></td>
<td><code>"ControlRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0x006A</code></th>
<td><code>"NumpadDivide"</code></td>
<td><code>"NumpadDivide"</code></td>
</tr>
<tr>
<th scope="row"><code>0x006B</code></th>
<td><code>"PrintScreen"</code></td>
<td><code>"PrintScreen"</code></td>
</tr>
<tr>
<th scope="row"><code>0x006C</code></th>
<td><code>"AltRight"</code></td>
<td><code>"AltRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0x006D</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x006E</code></th>
<td><code>"Home"</code></td>
<td><code>"Home"</code></td>
</tr>
<tr>
<th scope="row"><code>0x006F</code></th>
<td><code>"ArrowUp"</code></td>
<td><code>"ArrowUp"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0070</code></th>
<td><code>"PageUp"</code></td>
<td><code>"PageUp"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0071</code></th>
<td><code>"ArrowLeft"</code></td>
<td><code>"ArrowLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0072</code></th>
<td><code>"ArrowRight"</code></td>
<td><code>"ArrowRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0073</code></th>
<td><code>"End"</code></td>
<td><code>"End"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0074</code></th>
<td><code>"ArrowDown"</code></td>
<td><code>"ArrowDown"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0075</code></th>
<td><code>"PageDown"</code></td>
<td><code>"PageDown"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0076</code></th>
<td><code>"Insert"</code></td>
<td><code>"Insert"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0077</code></th>
<td><code>"Delete"</code></td>
<td><code>"Delete"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0078</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x0079</code></th>
<td><code>"VolumeMute"</code> (⚠️ Not the same on Chromium)</td>
<td>
<code>"AudioVolumeMute"</code> (was <code>"VolumeMute"</code> prior to
Chromium 52) (⚠️ Not the same on Firefox)
</td>
</tr>
<tr>
<th scope="row"><code>0x007A</code></th>
<td><code>"VolumeDown"</code> (⚠️ Not the same on Chromium)</td>
<td>
<code>"AudioVolumeDown"</code> (was <code>"VolumeDown"</code> prior to
Chromium 52) (⚠️ Not the same on Firefox)
</td>
</tr>
<tr>
<th scope="row"><code>0x007B</code></th>
<td><code>"VolumeUp"</code> (⚠️ Not the same on Chromium)</td>
<td>
<code>"AudioVolumeUp"</code> (was <code>"VolumeUp"</code> prior to Chromium
52) (⚠️ Not the same on Firefox)
</td>
</tr>
<tr>
<th scope="row"><code>0x007C</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"Power"</code> (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0x007D</code></th>
<td><code>"NumpadEqual"</code></td>
<td><code>"NumpadEqual"</code></td>
</tr>
<tr>
<th scope="row"><code>0x007E</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x007F</code></th>
<td><code>"Pause"</code></td>
<td><code>"Pause"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0080</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x0081</code></th>
<td><code>"NumpadComma"</code></td>
<td><code>"NumpadComma"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0082</code></th>
<td><code>"Lang1"</code></td>
<td><code>"Lang1"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0083</code></th>
<td><code>"Lang2"</code></td>
<td><code>"Lang2"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0084</code></th>
<td><code>"IntlYen"</code></td>
<td><code>"IntlYen"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0085</code></th>
<td><code>"MetaLeft"</code> (was <code>"OSLeft"</code> prior to Firefox 118)</td>
<td><code>"MetaLeft"</code> (was <code>"OSLeft"</code> prior to Chromium 52)</td>
</tr>
<tr>
<th scope="row"><code>0x0086</code></th>
<td><code>"MetaRight"</code> (was <code>"OSRight"</code> prior to Firefox 118)</td>
<td><code>"MetaRight"</code> (was <code>"OSRight"</code> prior to Chromium 52)</td>
</tr>
<tr>
<th scope="row"><code>0x0087</code></th>
<td><code>"ContextMenu"</code></td>
<td><code>"ContextMenu"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0088</code></th>
<td><code>"BrowserStop"</code></td>
<td><code>"BrowserStop"</code> (was <code>"Abort"</code> prior to Chromium 48)</td>
</tr>
<tr>
<th scope="row"><code>0x0089</code></th>
<td><code>"Again"</code></td>
<td><code>"Again"</code></td>
</tr>
<tr>
<th scope="row"><code>0x008A</code></th>
<td><code>"Props"</code> (⚠️ Not the same on Chromium)</td>
<td><code>""</code> (❌ Missing)</td>
</tr>
<tr>
<th scope="row"><code>0x008B</code></th>
<td><code>"Undo"</code></td>
<td><code>"Undo"</code></td>
</tr>
<tr>
<th scope="row"><code>0x008C</code></th>
<td><code>"Select"</code></td>
<td><code>"Select"</code> (was <code>""</code> prior to Chromium 48)</td>
</tr>
<tr>
<th scope="row"><code>0x008D</code></th>
<td><code>"Copy"</code></td>
<td><code>"Copy"</code></td>
</tr>
<tr>
<th scope="row"><code>0x008E</code></th>
<td><code>"Open"</code></td>
<td><code>"Open"</code> (was <code>""</code> prior to Chromium 48)</td>
</tr>
<tr>
<th scope="row"><code>0x008F</code></th>
<td><code>"Paste"</code></td>
<td><code>"Paste"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0090</code></th>
<td><code>"Find"</code></td>
<td><code>"Find"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0091</code></th>
<td><code>"Cut"</code></td>
<td><code>"Cut"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0092</code></th>
<td><code>"Help"</code></td>
<td><code>"Help"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0093</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x0094</code></th>
<td><code>"LaunchApp2"</code></td>
<td><code>"LaunchApp2"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0095</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x0096</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"Sleep"</code> (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0x0097</code></th>
<td><code>"WakeUp"</code></td>
<td><code>"WakeUp"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0098</code></th>
<td><code>"LaunchApp1"</code></td>
<td><code>"LaunchApp1"</code> (was <code>""</code> prior to Chromium 48)</td>
</tr>
<tr>
<th scope="row"><code>0x0099</code> ~ <code>0x00A2</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x00A3</code></th>
<td><code>"LaunchMail"</code></td>
<td><code>"LaunchMail"</code> (was <code>""</code> prior to Chromium 51)</td>
</tr>
<tr>
<th scope="row"><code>0x00A4</code></th>
<td><code>"BrowserFavorites"</code></td>
<td><code>"BrowserFavorites"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00A5</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x00A6</code></th>
<td><code>"BrowserBack"</code></td>
<td><code>"BrowserBack"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00A7</code></th>
<td><code>"BrowserForward"</code></td>
<td><code>"BrowserForward"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00A8</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x00A9</code></th>
<td><code>"Eject"</code></td>
<td><code>"Eject"</code> (was <code>""</code> prior to Chromium 48)</td>
</tr>
<tr>
<th scope="row"><code>0x00AA</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x00AB</code></th>
<td><code>"MediaTrackNext"</code></td>
<td><code>"MediaTrackNext"</code> (was <code>""</code> prior to Chromium 48)</td>
</tr>
<tr>
<th scope="row"><code>0x00AC</code></th>
<td><code>"MediaPlayPause"</code></td>
<td><code>"MediaPlayPause"</code> (was <code>""</code> prior to Chromium 48)</td>
</tr>
<tr>
<th scope="row"><code>0x00AD</code></th>
<td><code>"MediaTrackPrevious"</code></td>
<td><code>"MediaTrackPrevious"</code> (was <code>""</code> prior to Chromium 48)</td>
</tr>
<tr>
<th scope="row"><code>0x00AE</code></th>
<td><code>"MediaStop"</code></td>
<td><code>"MediaStop"</code> (was <code>""</code> prior to Chromium 48)</td>
</tr>
<tr>
<th scope="row"><code>0x00AF</code> ~ <code>0x00B2</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x00B3</code></th>
<td><code>"MediaSelect"</code></td>
<td><code>"MediaSelect"</code> (was <code>""</code> prior to Chromium 48)</td>
</tr>
<tr>
<th scope="row"><code>0x00B4</code></th>
<td><code>"BrowserHome"</code></td>
<td><code>"BrowserHome"</code> (was <code>""</code> prior to Chromium 48)</td>
</tr>
<tr>
<th scope="row"><code>0x00B5</code></th>
<td><code>"BrowserRefresh"</code></td>
<td><code>"BrowserRefresh"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00B6</code> ~ <code>0x00BA</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x00BB</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"NumpadParenLeft"</code> (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0x00BC</code></th>
<td><code>"Unidentified"</code> (❌ Missing)</td>
<td><code>"NumpadParenRight"</code> (⚠️ Not the same on Firefox)</td>
</tr>
<tr>
<th scope="row"><code>0x00BD</code>, <code>0x00BE</code></th>
<td><code>"Unidentified"</code></td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x00BF</code></th>
<td><code>"F13"</code></td>
<td><code>"F13"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C0</code></th>
<td><code>"F14"</code></td>
<td><code>"F14"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C1</code></th>
<td><code>"F15"</code></td>
<td><code>"F15"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C2</code></th>
<td><code>"F16"</code></td>
<td><code>"F16"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C3</code></th>
<td><code>"F17"</code></td>
<td><code>"F17"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C4</code></th>
<td><code>"F18"</code></td>
<td><code>"F18"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C5</code></th>
<td><code>"F19"</code></td>
<td><code>"F19"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C6</code></th>
<td><code>"F20"</code></td>
<td><code>"F20"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C7</code></th>
<td><code>"F21"</code></td>
<td><code>"F21"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C8</code></th>
<td><code>"F22"</code></td>
<td><code>"F22"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C9</code></th>
<td><code>"F23"</code></td>
<td><code>"F23"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00CA</code></th>
<td><code>"F24"</code></td>
<td><code>"F24"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00CB ~ 0x00E0</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
<td><code>""</code></td>
</tr>
<tr>
<th scope="row"><code>0x00E1</code></th>
<td><code>"BrowserSearch"</code> (⚠️ Not the same on Chromium)</td>
<td><code>"BrowserSearch"</code> (was <code>"BrightnessUp"</code> prior to Chromium 48)</td>
</tr>
</tbody>
</table>
## Code values on Firefox for Android
<table class="standard-table">
<thead>
<tr>
<th scope="row">scancode</th>
<th scope="col">Firefox</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><code>0x0001</code></th>
<td><code>"Escape"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0002</code></th>
<td><code>"Digit1"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0003</code></th>
<td><code>"Digit2"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0004</code></th>
<td><code>"Digit3"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0005</code></th>
<td><code>"Digit4"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0006</code></th>
<td><code>"Digit5"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0007</code></th>
<td><code>"Digit6"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0008</code></th>
<td><code>"Digit7"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0009</code></th>
<td><code>"Digit8"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000A</code></th>
<td><code>"Digit9"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000B</code></th>
<td><code>"Digit0"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000C</code></th>
<td><code>"Minus"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000D</code></th>
<td><code>"Equal"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000E</code></th>
<td><code>"Backspace"</code></td>
</tr>
<tr>
<th scope="row"><code>0x000F</code></th>
<td><code>"Tab"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0010</code></th>
<td><code>"KeyQ"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0011</code></th>
<td><code>"KeyW"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0012</code></th>
<td><code>"KeyE"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0013</code></th>
<td><code>"KeyR"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0014</code></th>
<td><code>"KeyT"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0015</code></th>
<td><code>"KeyY"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0016</code></th>
<td><code>"KeyU"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0017</code></th>
<td><code>"KeyI"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0018</code></th>
<td><code>"KeyO"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0019</code></th>
<td><code>"KeyP"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001A</code></th>
<td><code>"BracketLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001B</code></th>
<td><code>"BracketRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001C</code></th>
<td><code>"Enter"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001D</code></th>
<td><code>"ControlLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001E</code></th>
<td><code>"KeyA"</code></td>
</tr>
<tr>
<th scope="row"><code>0x001F</code></th>
<td><code>"KeyS"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0020</code></th>
<td><code>"KeyD"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0021</code></th>
<td><code>"KeyF"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0022</code></th>
<td><code>"KeyG"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0023</code></th>
<td><code>"KeyH"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0024</code></th>
<td><code>"KeyJ"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0025</code></th>
<td><code>"KeyK"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0026</code></th>
<td><code>"KeyL"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0027</code></th>
<td><code>"Semicolon"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0028</code></th>
<td><code>"Quote"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0029</code></th>
<td><code>"Backquote"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002A</code></th>
<td><code>"ShiftLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002B</code></th>
<td><code>"Backslash"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002C</code></th>
<td><code>"KeyZ"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002D</code></th>
<td><code>"KeyX"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002E</code></th>
<td><code>"KeyC"</code></td>
</tr>
<tr>
<th scope="row"><code>0x002F</code></th>
<td><code>"KeyV"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0030</code></th>
<td><code>"KeyB"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0031</code></th>
<td><code>"KeyN"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0032</code></th>
<td><code>"KeyM"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0033</code></th>
<td><code>"Comma"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0034</code></th>
<td><code>"Period"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0035</code></th>
<td><code>"Slash"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0036</code></th>
<td><code>"ShiftRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0037</code></th>
<td><code>"NumpadMultiply"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0038</code></th>
<td><code>"AltLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0039</code></th>
<td><code>"Space"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003A</code></th>
<td><code>"CapsLock"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003B</code></th>
<td><code>"F1"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003C</code></th>
<td><code>"F2"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003D</code></th>
<td><code>"F3"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003E</code></th>
<td><code>"F4"</code></td>
</tr>
<tr>
<th scope="row"><code>0x003F</code></th>
<td><code>"F5"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0040</code></th>
<td><code>"F6"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0041</code></th>
<td><code>"F7"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0042</code></th>
<td><code>"F8"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0043</code></th>
<td><code>"F9"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0044</code></th>
<td><code>"F10"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0045</code></th>
<td><code>"NumLock"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0046</code></th>
<td><code>"ScrollLock"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0047</code></th>
<td><code>"Numpad7"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0048</code></th>
<td><code>"Numpad8"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0049</code></th>
<td><code>"Numpad9"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004A</code></th>
<td><code>"NumpadSubtract"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004B</code></th>
<td><code>"Numpad4"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004C</code></th>
<td><code>"Numpad5"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004D</code></th>
<td><code>"Numpad6"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004E</code></th>
<td><code>"NumpadAdd"</code></td>
</tr>
<tr>
<th scope="row"><code>0x004F</code></th>
<td><code>"Numpad1"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0050</code></th>
<td><code>"Numpad2"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0051</code></th>
<td><code>"Numpad3"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0052</code></th>
<td><code>"Numpad0"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0053</code></th>
<td><code>"NumpadDecimal"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0054</code>, <code>0x0055</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x0056</code></th>
<td><code>"IntlBackslash"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0057</code></th>
<td><code>"F11"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0058</code></th>
<td><code>"F12"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0059</code></th>
<td><code>"IntlRo"</code></td>
</tr>
<tr>
<th scope="row"><code>0x005A</code>, <code>0x005B</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x005C</code></th>
<td><code>"Convert"</code></td>
</tr>
<tr>
<th scope="row"><code>0x005D</code></th>
<td><code>"KanaMode"</code></td>
</tr>
<tr>
<th scope="row"><code>0x005E</code></th>
<td><code>"NonConvert"</code></td>
</tr>
<tr>
<th scope="row"><code>0x005F</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x0060</code></th>
<td><code>"NumpadEnter"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0061</code></th>
<td><code>"ControlRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0062</code></th>
<td><code>"NumpadDivide"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0063</code></th>
<td><code>"PrintScreen"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0064</code></th>
<td><code>"AltRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0065</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x0066</code></th>
<td><code>"Home"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0067</code></th>
<td><code>"ArrowUp"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0068</code></th>
<td><code>"PageUp"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0069</code></th>
<td><code>"ArrowLeft"</code></td>
</tr>
<tr>
<th scope="row"><code>0x006A</code></th>
<td><code>"ArrowRight"</code></td>
</tr>
<tr>
<th scope="row"><code>0x006B</code></th>
<td><code>"End"</code></td>
</tr>
<tr>
<th scope="row"><code>0x006C</code></th>
<td><code>"ArrowDown"</code></td>
</tr>
<tr>
<th scope="row"><code>0x006D</code></th>
<td><code>"PageDown"</code></td>
</tr>
<tr>
<th scope="row"><code>0x006E</code></th>
<td><code>"Insert"</code></td>
</tr>
<tr>
<th scope="row"><code>0x006F</code></th>
<td><code>"Delete"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0070</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x0071</code></th>
<td>
<p><code>"VolumeMute"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x0072</code></th>
<td>
<p><code>"VolumeDown"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x0073</code></th>
<td>
<p><code>"VolumeUp"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x0074</code></th>
<td><code>"Power"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0075</code></th>
<td><code>"NumpadEqual"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0076</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x0077</code></th>
<td><code>"Pause"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0078</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x0079</code></th>
<td><code>"NumpadComma"</code></td>
</tr>
<tr>
<th scope="row"><code>0x007A</code></th>
<td><code>"Lang1"</code></td>
</tr>
<tr>
<th scope="row"><code>0x007B</code></th>
<td><code>"Lang2"</code></td>
</tr>
<tr>
<th scope="row"><code>0x007C</code></th>
<td><code>"IntlYen"</code></td>
</tr>
<tr>
<th scope="row"><code>0x007D</code></th>
<td>
<p><code>"MetaLeft"</code> (was <code>"OSLeft"</code> prior to Firefox 118)</p>
</td>
</tr>
<tr>
<th scope="row"><code>0x007E</code></th>
<td>
<p><code>"MetaRight"</code> (was <code>"OSRight"</code> prior to Firefox 118)</p>
</td>
</tr>
<tr>
<th scope="row"><code>0x007F</code></th>
<td><code>"ContextMenu"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0080</code></th>
<td><code>"BrowserStop"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0081</code></th>
<td>"Again"</td>
</tr>
<tr>
<th scope="row"><code>0x0082</code></th>
<td><code>"Props"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0083</code></th>
<td><code>"Undo"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0084</code></th>
<td><code>"Select"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0085</code></th>
<td><code>"Copy"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0086</code></th>
<td><code>"Open"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0087</code></th>
<td><code>"Paste"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0088</code></th>
<td><code>"Find"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0089</code></th>
<td><code>"Cut"</code></td>
</tr>
<tr>
<th scope="row"><code>0x008A</code></th>
<td><code>"Help"</code></td>
</tr>
<tr>
<th scope="row"><code>0x008B</code> ~ <code>0x008D</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x008E</code></th>
<td><code>"Sleep"</code></td>
</tr>
<tr>
<th scope="row"><code>0x008F</code></th>
<td><code>"WakeUp"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0090</code></th>
<td><code>"LaunchApp1"</code></td>
</tr>
<tr>
<th scope="row"><code>0x0091</code> ~ <code>0x009B</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x009C</code></th>
<td><code>"BrowserFavorites"</code></td>
</tr>
<tr>
<th scope="row"><code>0x009D</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x009E</code></th>
<td><code>"BrowserBack"</code></td>
</tr>
<tr>
<th scope="row"><code>0x009F</code></th>
<td><code>"BrowserForward"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00A0</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x00A1</code></th>
<td><code>"Eject"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00A2</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x00A3</code></th>
<td><code>"MediaTrackNext"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00A4</code></th>
<td><code>"MediaPlayPause"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00A5</code></th>
<td><code>"MediaTrackPrevious"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00A6</code></th>
<td><code>"MediaStop"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00A7</code> ~ <code>0x00AC</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x00AD</code></th>
<td><code>"BrowserRefresh"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00AE</code> ~ <code>0x00B6</code></th>
<td>"Unidentified"</td>
</tr>
<tr>
<th scope="row"><code>0x00B7</code></th>
<td><code>"F13"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00B8</code></th>
<td><code>"F14"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00B9</code></th>
<td><code>"F15"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00BA</code></th>
<td><code>"F16"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00BB</code></th>
<td><code>"F17"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00BC</code></th>
<td><code>"F18"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00BD</code></th>
<td><code>"F19"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00BE</code></th>
<td><code>"F20"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00BF</code></th>
<td><code>"F21"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C0</code></th>
<td><code>"F22"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C1</code></th>
<td><code>"F23"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C2</code></th>
<td><code>"F24"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00C3</code> ~ <code>0x00D8</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x00D9</code></th>
<td><code>"BrowserSearch"</code></td>
</tr>
<tr>
<th scope="row"><code>0x00DA</code> ~ <code>0x01CF</code></th>
<td>
<p><code>"Unidentified"</code></p>
</td>
</tr>
<tr>
<th scope="row"><code>0x01D0</code></th>
<td><code>"Fn"</code></td>
</tr>
</tbody>
</table>
| 0 |
data/mdn-content/files/en-us/web/api/ui_events | data/mdn-content/files/en-us/web/api/ui_events/keyboard_event_key_values/index.md | ---
title: Key values for keyboard events
slug: Web/API/UI_Events/Keyboard_event_key_values
page-type: guide
---
{{DefaultAPISidebar("UI Events")}}
The tables below list the standard values for the [`KeyboardEvent.key`](/en-US/docs/Web/API/KeyboardEvent/key) property, with an explanation of what the key is typically used for. Corresponding virtual keycodes for common platforms are included where available.
## Special values
Values of `key` which have special meanings other than identifying a specific key or character.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"Unidentified"</code></td>
<td>
<p>
The user agent wasn't able to map the event's virtual keycode to a
specific key value.
</p>
<p>
This can happen due to hardware or software constraints, or because of
constraints around the platform on which the user agent is running.
</p>
</td>
<td><em>varies</em></td>
<td><em>varies</em></td>
<td><em>varies</em></td>
<td><em>varies</em></td>
</tr>
</tbody>
</table>
## Modifier keys
_Modifiers_ are special keys which are used to generate special characters or cause special actions when used in combination with other keys. Examples include the <kbd>Shift</kbd> and <kbd>Control</kbd> keys, and lock keys such as <kbd>Caps Lock</kbd> and <kbd>NumLock</kbd>.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"Alt"</code> [4]</td>
<td>The <kbd>Alt</kbd> (Alternative) key.</td>
<td>
<code>VK_MENU</code> (0x12)<br /><code>VK_LMENU</code> (0xA4)<br /><code
>VK_RMENU</code
>
(0xA5)
</td>
<td>
<code>kVK_Option</code> (0x3A)<br /><code>kVK_RightOption</code> (0x3D)
</td>
<td>
<code>GDK_KEY_Alt_L</code> (0xFFE9)<br /><code>GDK_KEY_Alt_R</code>
(0xFFEA)<br /><code>Qt::Key_Alt</code> (0x01000023)
</td>
<td>
<code>KEYCODE_ALT_LEFT</code> (57)<br /><code>KEYCODE_ALT_RIGHT</code>
(58)
</td>
</tr>
<tr>
<td><code>"AltGraph"</code> [4]</td>
<td>
The <kbd>AltGr</kbd> or <kbd>AltGraph</kbd> (Alternate Graphics) key.
Enables the ISO Level 3 shift modifier (where <kbd>Shift</kbd> is the
level 2 modifier).
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Mode_switch</code> (0xFF7E)<br /><code
>GDK_KEY_ISO_Level3_Shift</code
>
(0xFE03)<br /><code>GDK_KEY_ISO_Level3_Latch</code> (0xFE04)<br /><code
>GDK_KEY_ISO_Level3_Lock</code
>
(0xFE05)<br /><code>GDK_KEY_ISO_Level5_Shift</code> (0xFE11)<br /><code
>GDK_KEY_ISO_Level5_Latch</code
>
(0xFE12)<br /><code>GDK_KEY_ISO_Level5_Lock</code> (0xFE13)<br /><code
>Qt::Key_AltGr</code
>
(0x01001103<br /><code>Qt::Key_Mode_switch</code> (0x0100117E)
</td>
<td></td>
</tr>
<tr>
<td><code>"CapsLock"</code></td>
<td>
The <kbd>Caps Lock</kbd> key. Toggles the capital character lock on and
off for subsequent input.
</td>
<td><code>VK_CAPITAL</code> (0x14)</td>
<td><code>kVK_CapsLock</code> (0x39)</td>
<td>
<code>GDK_KEY_Caps_Lock</code> (0xFFE5)<br /><code
>Qt::Key_CapsLock</code
>
(0x01000024)
</td>
<td><code>KEYCODE_CAPS_LOCK</code> (115)</td>
</tr>
<tr>
<td><code>"Control"</code></td>
<td>
The <kbd>Control</kbd>, <kbd>Ctrl</kbd>, or <kbd>Ctl</kbd> key. Allows
typing control characters.
</td>
<td>
<code>VK_CONTROL</code> (0x11)<br /><code>VK_LCONTROL</code>
(0xA2)<br /><code>VK_RCONTROL</code> (0xA3)
</td>
<td>
<code>kVK_Control</code> (0x3B)<br /><code>kVK_RightControl</code>
(0x3E)
</td>
<td>
<code>GDK_KEY_Control_L</code> (0xFFE3)<br /><code
>GDK_KEY_Control_R</code
>
(0xFFE4)<br /><code>Qt::Key_Control</code> (0x01000021)
</td>
<td>
<code>KEYCODE_CTRL_LEFT</code> (113)<br /><code
>KEYCODE_CTRL_RIGHT</code
>
(114)
</td>
</tr>
<tr>
<td><code>"Fn"</code></td>
<td>
The <kbd>Fn</kbd> (Function modifier) key. Used to allow generating
function key (<kbd>F1</kbd>–<kbd>F15</kbd>, for instance) characters on
keyboards without a dedicated function key area. Often handled in
hardware so that events aren't generated for this key.
</td>
<td></td>
<td><code>kVK_Function</code> (0x3F)</td>
<td></td>
<td><code>KEYCODE_FUNCTION</code> (119)</td>
</tr>
<tr>
<td><code>"FnLock"</code></td>
<td>
The <kbd>FnLock</kbd> or <kbd>F-Lock</kbd> (Function Lock) key.Toggles
the function key mode described by <code>"Fn"</code> on and off. Often
handled in hardware so that events aren't generated for this key.
</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"Hyper"</code> [3]</td>
<td>The <kbd>Hyper</kbd> key.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Hyper_L</code> (0xFFED)<br /><code>GDK_KEY_Hyper_R</code>
(0xFFEE)<br /><code>Qt::Key_Hyper_L</code> (0x01000056)<br /><code
>Qt::Key_Hyper_R</code
>
(0x01000057)
</td>
<td></td>
</tr>
<tr>
<td><code>"Meta"</code> [1]</td>
<td>
The <kbd>Meta</kbd> key. Allows issuing special command inputs. This is
the <kbd>Windows</kbd> logo key, or the <kbd>Command</kbd> or
<kbd>⌘</kbd> key on Mac keyboards.
</td>
<td><code>VK_LWIN</code> (0x5B)<br /><code>VK_RWIN</code> (0x5C)</td>
<td>
<code>kVK_Command</code> (0x37)<br /><code>kVK_RightCommand</code>
(0x36)
</td>
<td>
<code>GDK_KEY_Meta_L</code> (0xFFE7)<br /><code>GDK_KEY_Meta_R</code>
(0xFFE8)<br /><code>Qt::Key_Meta</code> (0x01000022)
</td>
<td>
<code>KEYCODE_META_LEFT</code> (117)<br /><code
>KEYCODE_META_RIGHT</code
>
(118)
</td>
</tr>
<tr>
<td><code>"NumLock"</code></td>
<td>
The <kbd>NumLock</kbd> (Number Lock) key. Toggles the numeric keypad
between number entry some other mode (often directional arrows).
</td>
<td><code>VK_NUMLOCK</code> (0x90)</td>
<td></td>
<td>
<code>GDK_KEY_Num_Lock</code> (0xFF7F)<br /><code>Qt::Key_NumLock</code>
(0x01000025)
</td>
<td><code>KEYCODE_NUM_LOCK</code> (143)</td>
</tr>
<tr>
<td><code>"ScrollLock"</code> [2]</td>
<td>
The <kbd>Scroll Lock</kbd> key. Toggles between scrolling and cursor
movement modes.
</td>
<td><code>VK_SCROLL</code> (0x91)</td>
<td></td>
<td>
<code>GDK_KEY_Scroll_Lock</code> (0xFF14)<br /><code
>Qt::Key_ScrollLock</code
>
(0x01000026)
</td>
<td><code>KEYCODE_SCROLL_LOCK</code> (116)</td>
</tr>
<tr>
<td><code>"Shift"</code></td>
<td>
The <kbd>Shift</kbd> key. Modifies keystrokes to allow typing upper (or
other) case letters, and to support typing punctuation and other special
characters.
</td>
<td>
<code>VK_SHIFT</code> (0x10)<br /><code>VK_LSHIFT</code>
(0xA0)<br /><code>VK_RSHIFT</code> (0xA1)
</td>
<td>
<code>kVK_Shift</code> (0x38)<br /><code>kVK_RightShift</code> (0x3C)
</td>
<td>
<code>GDK_KEY_Shift_L</code> (0xFFE1)<br /><code>GDK_KEY_Shift_R</code>
(0xFFE2)<br /><code>Qt::Key_Shift</code> (0x01000020)
</td>
<td>
<code>KEYCODE_SHIFT_LEFT</code> (59)<br /><code
>KEYCODE_SHIFT_RIGHT</code
>
(60)
</td>
</tr>
<tr>
<td><code>"Super"</code> [3]</td>
<td>The <kbd>Super</kbd> key.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Super_L</code> (0xFFEB)<br /><code>GDK_KEY_Super_R</code>
(0xFFEC)<br /><code>Qt::Key_Super_L</code> (0x01000053)<br /><code
>Qt::Key_Super_R</code
>
(0x01000054)
</td>
<td></td>
</tr>
<tr>
<td><code>"Symbol"</code></td>
<td>
The <kbd>Symbol</kbd> modifier key (found on certain virtual keyboards).
</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_SYM</code> (63) [2]</td>
</tr>
<tr>
<td><code>"SymbolLock"</code></td>
<td>The <kbd>Symbol Lock</kbd> key.</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
\[1] In Firefox, the <kbd>Windows</kbd> key is reported as `"OS"` instead of as `"Meta"`. This will be changed in Firefox per [Firefox bug 1232918](https://bugzil.la/1232918). Until that's fixed, these keys are returned as `"OS"` by Firefox: `VK_LWIN` (0x5B) and `VK_RWIN` (0x5C) on Windows, and `GDK_KEY_Super_L` (0xFFEB), `GDK_KEY_Super_R` (0xFFEC), `GDK_KEY_Hyper_L` (0xFFED), and `GDK_KEY_Hyper_R` (0xFFEE) on Linux.
\[2] Firefox did not add support for the <kbd>Symbol</kbd> key until Firefox 37.
\[3] Firefox generates the key value `"OS`" for the <kbd>Super</kbd> and <kbd>Hyper</kbd> keys, instead of `"Super"` and `"Hyper"`.
\[4] Chrome 67 and Firefox 63 now correctly interpret the right <kbd>Alt</kbd> key for keyboard layouts which map that key to <kbd>AltGr</kbd>. See Firefox bug [Firefox bug 900750](https://bugzil.la/900750) and [Chrome bug 25503](https://crbug.com/25503) for further details.
## Whitespace keys
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"Enter"</code></td>
<td>
The <kbd>Enter</kbd> or <kbd>↵</kbd> key (sometimes labeled
<kbd>Return</kbd>).
</td>
<td><code>VK_RETURN</code> (0x0D)</td>
<td>
<code>kVK_Return</code> (0x24)<br /><code>kVK_ANSI_KeypadEnter</code>
(0x4C)<br /><code>kVK_Powerbook_KeypadEnter</code> (0x34)
</td>
<td>
<code>GDK_KEY_Return</code> (0xFF0D)<br /><code>GDK_KEY_KP_Enter</code>
(0xFF8D)<br /><code>GDK_KEY_ISO_Enter</code> (0xFE34)<br /><code
>GDK_KEY_3270_Enter</code
>
(0xFD1E)<br /><code>Qt::Key_Return</code> (0x01000004)<br /><code
>Qt::Key_Enter</code
>
(0x01000005)
</td>
<td>
<code>KEYCODE_ENTER</code> (66)<br /><code>KEYCODE_NUMPAD_ENTER</code>
(160)<br /><code>KEYCODE_DPAD_CENTER</code> (23)
</td>
</tr>
<tr>
<td><code>"Tab"</code></td>
<td>The Horizontal Tab key, <kbd>Tab</kbd>.</td>
<td><code>VK_TAB</code> (0x09)</td>
<td><code>kVK_Tab</code> (0x30)</td>
<td>
<code>GDK_KEY_Tab</code> (0xFF09)<br /><code>GDK_KEY_KP_Tab</code>
(0xFF89)<br /><code>GDK_KEY_ISO_Left_Tab</code> (0xFE20)<br /><code
>Qt::Key_Tab</code
>
(0x01000001)
</td>
<td><code>KEYCODE_TAB</code> (61)</td>
</tr>
<tr>
<td><code>" "</code> [1]</td>
<td>The space key, <kbd>Space Bar</kbd>.</td>
<td><code>VK_SPACE</code> (0x20)</td>
<td><code>kVK_Space</code> (0x31)</td>
<td>
<p>
<code>GDK_KEY_space</code> (0x20)<br /><code>GDK_KEY_KP_Space</code>
(0xFF80)<br /><code>Qt::Key_Space</code> (0x20)
</p>
</td>
<td><code>KEYCODE_SPACE</code> (62)</td>
</tr>
</tbody>
</table>
\[1] Older browsers may return `"Spacebar"` instead of `" "` for the <kbd>Space Bar</kbd> key. Firefox did so until version 37.
## Navigation keys
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"ArrowDown"</code> [1]</td>
<td>The down arrow key.</td>
<td><code>VK_DOWN</code> (0x28)</td>
<td><code>kVK_DownArrow</code> (0x7D)</td>
<td>
<code>GDK_KEY_Down</code> (0xFF54)<br /><code>GDK_KEY_KP_Down</code>
(0xFF99)<br /><code>Qt::Key_Down</code> (0x01000015)
</td>
<td><code>KEYCODE_DPAD_DOWN</code> (20)</td>
</tr>
<tr>
<td><code>"ArrowLeft"</code> [1]</td>
<td>The left arrow key.</td>
<td><code>VK_LEFT</code> (0x25)</td>
<td><code>kVK_LeftArrow</code> (0x7B)</td>
<td>
<code>GDK_KEY_Left</code> (0xFF51)<br /><code>GDK_KEY_KP_Left</code>
(0xFF96)<br /><code>Qt::Key_Left</code> (0x01000012)
</td>
<td><code>KEYCODE_DPAD_LEFT</code> (21)</td>
</tr>
<tr>
<td><code>"ArrowRight"</code> [1]</td>
<td>The right arrow key.</td>
<td><code>VK_RIGHT</code> (0x27)</td>
<td><code>kVK_RightArrow</code> (0x7C)</td>
<td>
<code>GDK_KEY_Right</code> (0xFF53)<br /><code>GDK_KEY_KP_Right</code>
(0xFF98)<br /><code>Qt::Key_Right</code> (0x01000014)
</td>
<td><code>KEYCODE_DPAD_RIGHT</code> (22)</td>
</tr>
<tr>
<td><code>"ArrowUp"</code> [1]</td>
<td>The up arrow key.</td>
<td><code>VK_UP</code><code> (0x26)</code></td>
<td><code>kVK_UpArrow</code> (0x7E)</td>
<td>
<code>GDK_KEY_Up</code> (0xFF52)<br /><code>GDK_KEY_KP_Up</code>
(0xFF97)<br /><code>Qt::Key_Up</code> (0x01000013)
</td>
<td><code>KEYCODE_DPAD_UP</code> (19)</td>
</tr>
<tr>
<td><code>"End"</code></td>
<td>The <kbd>End</kbd> key. Moves to the end of content.</td>
<td><code>VK_END</code> (0x23)</td>
<td><code>kVK_End</code> (0x77)</td>
<td>
<code>GDK_KEY_End</code> (0xFF57)<br /><code>GDK_KEY_KP_End</code>
(0xFF9C)<br /><code>Qt::Key_End</code> (0x01000011)
</td>
<td><code>KEYCODE_MOVE_END</code> (123)</td>
</tr>
<tr>
<td><code>"Home"</code></td>
<td>The <kbd>Home</kbd> key. Moves to the start of content.</td>
<td><code>VK_HOME</code> (0x24)</td>
<td><code>kVK_Home</code> (0x73)</td>
<td>
<code>GDK_KEY_Home</code> (0xFF50)<br /><code>GDK_KEY_KP_Home</code>
(0xFF95)<br /><code>Qt::Key_Home</code> (0x01000010)
</td>
<td><code>KEYCODE_MOVE_HOME</code> (122)</td>
</tr>
<tr>
<td><code>"PageDown"</code></td>
<td>
The <kbd>Page Down</kbd> (or <kbd>PgDn</kbd>) key. Scrolls down or
displays the next page of content.
</td>
<td><code>VK_NEXT</code> (0x22)</td>
<td><code>kVK_PageDown</code><code> (0x79)</code></td>
<td>
<code>GDK_KEY_Page_Down</code> (0xFF56)<br /><code
>GDK_KEY_KP_Page_Down</code
>
(0xFF9B)<br /><code>Qt::Key_PageDown</code> (0x01000017)
</td>
<td><code>KEYCODE_PAGE_DOWN</code> (93)</td>
</tr>
<tr>
<td><code>"PageUp"</code></td>
<td>
The <kbd>Page Up</kbd> (or <kbd>PgUp</kbd>) key. Scrolls up or displays
the previous page of content.
</td>
<td><code>VK_PRIOR</code> (0x21)</td>
<td><code>kVK_PageUp</code> (0x74)</td>
<td>
<code>GDK_KEY_Page_Up</code> (0xFF55)<br /><code
>GDK_KEY_KP_Page_Up</code
>
(0xFF9A)<br /><code>Qt::Key_PageUp</code> (0x01000016)
</td>
<td><code>KEYCODE_PAGE_UP</code> (92)</td>
</tr>
</tbody>
</table>
\[1] Edge (16 and earlier) and Firefox (36 and earlier) use `"Left"`, `"Right"`, `"Up"`, and `"Down"` instead of `"ArrowLeft"`, `"ArrowRight"`, `"ArrowUp"`, and `"ArrowDown"`.
## Editing keys
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"Backspace"</code></td>
<td>
The <kbd>Backspace</kbd> key. This key is labeled <kbd>Delete</kbd> on
Mac keyboards.
</td>
<td><code>VK_BACK</code> (0x08)</td>
<td><code>kVK_Delete</code> (0x33)</td>
<td>
<code>GDK_KEY_BackSpace</code> (0xFF08)<br /><code
>Qt::Key_Backspace</code
>
(0x01000003)
</td>
<td><code>KEYCODE_DEL</code> (67)</td>
</tr>
<tr>
<td><code>"Clear"</code></td>
<td>The <kbd>Clear</kbd> key. Removes the currently selected input.</td>
<td>
<code>VK_CLEAR</code> (0x0C)<br /><code>VK_OEM_CLEAR</code> (0xFE)
</td>
<td><code>kVK_ANSI_KeypadClear</code> (0x47)</td>
<td>
<code>GDK_KEY_Clear</code> (0xFF0B)<br /><code>Qt::Key_Clear</code>
(0x0100000B)
</td>
<td><code>KEYCODE_CLEAR</code> (28)</td>
</tr>
<tr>
<td><code>"Copy"</code></td>
<td>The <kbd>Copy</kbd> key (on certain extended keyboards).</td>
<td><code>APPCOMMAND_COPY</code></td>
<td></td>
<td>
<code>GDK_KEY_Copy</code> (0x1008FF57)<br /><code>Qt::Key_Copy</code>
(0x010000CF)
</td>
<td></td>
</tr>
<tr>
<td><code>"CrSel"</code> [3]</td>
<td>The Cursor Select key, <kbd>CrSel</kbd>.</td>
<td><code>VK_CRSEL</code> (0xF7)</td>
<td></td>
<td><code>GDK_KEY_3270_CursorSelect</code> (0xFD1C)</td>
<td></td>
</tr>
<tr>
<td><code>"Cut"</code></td>
<td>The <kbd>Cut</kbd> key (on certain extended keyboards).</td>
<td><code>APPCOMMAND_CUT</code></td>
<td></td>
<td>
<code>GDK_KEY_Cut</code> (0x1008FF58)<br /><code>Qt::Key_Cut</code>
(0x010000D0)
</td>
<td></td>
</tr>
<tr>
<td><code>"Delete"</code> [2]</td>
<td>The Delete key, <kbd>Del</kbd>.</td>
<td><code>VK_DELETE</code> (0x2E)</td>
<td><code>kVK_ForwardDelete</code> (0x75) [1]</td>
<td>
<code>GDK_KEY_Delete</code> (0xFFFF)<br /><code>GDK_KEY_KP_Delete</code>
(0xFF9F)<br /><code>Qt::Key_Delete</code> (0x01000007)
</td>
<td><code>KEYCODE_FORWARD_DEL</code> (112)</td>
</tr>
<tr>
<td><code>"EraseEof"</code></td>
<td>
Erase to End of Field. Deletes all characters from the current cursor
position to the end of the current field.
</td>
<td><code>VK_EREOF</code> (0xF9)</td>
<td></td>
<td><code>GDK_KEY_3270_ExSelect</code> (0xFD1B)</td>
<td></td>
</tr>
<tr>
<td><code>"ExSel"</code> [4]</td>
<td>The <kbd>ExSel</kbd> (Extend Selection) key.</td>
<td><code>VK_EXSEL</code> (0xF8)</td>
<td></td>
<td><code>GDK_KEY_3270_ExSelect</code> (0xFD1B)</td>
<td></td>
</tr>
<tr>
<td><code>"Insert"</code></td>
<td>
The Insert key, <kbd>Ins</kbd>. Toggles between inserting and
overwriting text.
</td>
<td><code>VK_INSERT</code> (0x2D)</td>
<td></td>
<td>
<code>GDK_KEY_Insert</code> (0xFF63)<br /><code>GDK_KEY_KP_Insert</code>
(0xFF9E)<br /><code>Qt::Key_Insert</code> (0x01000006)
</td>
<td><code>KEYCODE_INSERT</code> (124)</td>
</tr>
<tr>
<td><code>"Paste"</code></td>
<td>Paste from the clipboard.</td>
<td><code>APPCOMMAND_PASTE</code></td>
<td></td>
<td>
<code>GDK_KEY_Paste</code> (0x1008FF6D)<br /><code>Qt::Key_Paste</code>
(0x010000E2)
</td>
<td></td>
</tr>
<tr>
<td><code>"Redo"</code></td>
<td>Redo the last action.</td>
<td><code>APPCOMMAND_REDO</code></td>
<td></td>
<td><code>GDK_KEY_Redo</code> (0xFF66)</td>
<td></td>
</tr>
<tr>
<td><code>"Undo"</code></td>
<td>Undo the last action.</td>
<td><code>APPCOMMAND_UNDO</code></td>
<td></td>
<td><code>GDK_KEY_Undo</code> (0xFF65)</td>
<td></td>
</tr>
</tbody>
</table>
\[1] On keyboards without a dedicated <kbd>Del</kbd> key, the Mac generates the `"Delete"` value when <kbd>Fn</kbd> is pressed in tandem with <kbd>Delete</kbd> (which is <kbd>Backspace</kbd> on other platforms).
\[2] Firefox 36 and earlier uses `"Del"` instead of `"Delete"` for the <kbd>Del</kbd> key.
\[3] Firefox 36 and earlier generates the value `"Crsel"` instead of `"CrSel"` when the <kbd>CrSel</kbd> key is pressed.
\[4] Firefox 36 and earlier generates the value `"Exsel"` instead of `"ExSel"` when the <kbd>ExSel</kbd> key is pressed.
## UI keys
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"Accept"</code></td>
<td>
The <kbd>Accept</kbd>, <kbd>Commit</kbd>, or <kbd>OK</kbd> key or
button. Accepts the currently selected option or input method sequence
conversion.
</td>
<td><code>VK_ACCEPT</code> (0x1E)</td>
<td></td>
<td></td>
<td><code>KEYCODE_DPAD_CENTER</code> (23)</td>
</tr>
<tr>
<td><code>"Again"</code></td>
<td>The <kbd>Again</kbd> key. Redoes or repeats a previous action.</td>
<td></td>
<td></td>
<td><code>GDK_KEY_Redo</code> (0xFF66)</td>
<td></td>
</tr>
<tr>
<td><code>"Attn"</code> [4]</td>
<td>The <kbd>Attn</kbd> (Attention) key.</td>
<td><code>VK_OEM_ATTN</code> (0xF0)</td>
<td></td>
<td><code>GDK_KEY_3270_Attn</code> (0xFD0E)</td>
<td></td>
</tr>
<tr>
<td><code>"Cancel"</code> [1]</td>
<td>The <kbd>Cancel</kbd> key.</td>
<td></td>
<td></td>
<td><code>GDK_KEY_Cancel</code> (0xFF69)</td>
<td></td>
</tr>
<tr>
<td><code>"ContextMenu"</code> [3]</td>
<td>
Shows the context menu. Typically found between the
<kbd>Windows</kbd> (or <kbd>OS</kbd>) key and the <kbd>Control</kbd> key
on the right side of the keyboard.
</td>
<td><code>VK_APPS</code> (0x5D)</td>
<td><code>kVK_PC_ContextMenu</code> (0x6E)</td>
<td>
<code>GDK_KEY_Menu</code> (0xFF67)<br /><code>Qt::Key_Menu</code>
(0x01000055)
</td>
<td><code>KEYCODE_MENU</code> (82)</td>
</tr>
<tr>
<td><code>"Escape"</code> [2]</td>
<td>
The <kbd>Esc</kbd> (Escape) key. Typically used as an exit, cancel, or
"escape this operation" button. Historically, the Escape character was
used to signal the start of a special control sequence of characters
called an "escape sequence."
</td>
<td><code>VK_ESCAPE</code> (0x1B)</td>
<td><code>kVK_Escape</code> (0x35)</td>
<td>
<code>GDK_KEY_Escape</code> (0xFF1B)<br /><code>Qt::Key_Escape</code>
(0x01000000)
</td>
<td><code>KEYCODE_ESCAPE</code> (111)</td>
</tr>
<tr>
<td><code>"Execute"</code></td>
<td>The <kbd>Execute</kbd> key.</td>
<td><code>VK_EXECUTE</code> (0x2B)</td>
<td></td>
<td><code>Qt::Key_Execute</code> (0x01020003)</td>
<td></td>
</tr>
<tr>
<td><code>"Find"</code></td>
<td>
The <kbd>Find</kbd> key. Opens an interface (typically a dialog box) for
performing a find/search operation.
</td>
<td><code>APPCOMMAND_FIND</code></td>
<td></td>
<td><code>GDK_KEY_Find</code> (0xFF68)</td>
<td></td>
</tr>
<tr>
<td><code>"Finish"</code> [5]</td>
<td>The <kbd>Finish</kbd> key.</td>
<td><code>VK_OEM_FINISH</code> (0xF1)</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"Help"</code></td>
<td>
The <kbd>Help</kbd> key. Opens or toggles the display of help
information.
</td>
<td><code>VK_HELP</code> (0x2F)<br /><code>APPCOMMAND_HELP</code></td>
<td><code>kVK_Help</code> (0x72)</td>
<td>
<code>GDK_KEY_Help</code> (0xFF6A)<br /><code>Qt::Key_Help</code>
(0x01000058)
</td>
<td><code>KEYCODE_HELP</code> (259)</td>
</tr>
<tr>
<td><code>"Pause"</code></td>
<td>
The <kbd>Pause</kbd> key. Pauses the current application or state, if
applicable.
<div class="note">
<p>
<strong>Note:</strong> This shouldn't be confused with the
<code>"MediaPause"</code> key value, which is used for media
controllers, rather than to control applications and processes.
</p>
</div>
</td>
<td><code>VK_PAUSE</code> (0x13)</td>
<td></td>
<td>
<code>GDK_KEY_Pause</code> (0xFF13)<br /><code>GDK_KEY_Break</code>
(0xFF6B)<br /><code>Qt::Key_Pause</code> (0x01000008)
</td>
<td><code>KEYCODE_BREAK</code> (121)</td>
</tr>
<tr>
<td><code>"Play"</code></td>
<td>
The <kbd>Play</kbd> key. Resumes a previously paused application, if
applicable.
<div class="note">
<p>
<strong>Note:</strong> This shouldn't be confused with the
<code>"MediaPlay"</code> key value, which is used for media
controllers, rather than to control applications and processes.
</p>
</div>
</td>
<td><code>VK_PLAY</code> (0xFA)</td>
<td></td>
<td>
<code>GDK_KEY_3270_Play</code> (0xFD16)<br /><code>Qt::Key_Play</code>
(0x01020005)
</td>
<td></td>
</tr>
<tr>
<td><code>"Props"</code></td>
<td>The <kbd>Props</kbd> (Properties) key.</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"Select"</code></td>
<td>The <kbd>Select</kbd> key.</td>
<td><code>VK_SELECT</code> (0x29)</td>
<td></td>
<td><code>GDK_KEY_Select</code> (0xFF60)</td>
<td><code>KEYCODE_BUTTON_SELECT</code> (109)</td>
</tr>
<tr>
<td><code>"ZoomIn"</code> [6]</td>
<td>The <kbd>ZoomIn</kbd> key.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_ZoomIn</code> (0x1008FF8B)<br /><code
>Qt::Key_ZoomIn</code
>
(0x010000F6)
</td>
<td><code>KEYCODE_ZOOM_IN</code> (168)</td>
</tr>
<tr>
<td><code>"ZoomOut"</code> [6]</td>
<td>The <kbd>ZoomOut</kbd> key.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_ZoomOut</code> (0x1008FF8C)<br /><code
>Qt::Key_ZoomOut</code
>
(0x010000F7)
</td>
<td><code>KEYCODE_ZOOM_OUT</code> (169)</td>
</tr>
</tbody>
</table>
\[1] In Google Chrome 52, the <kbd>Cancel</kbd> key incorrectly returns the key code `"Pause"`. This is fixed in Chrome 53. (See [Chrome bug 612749](https://crbug.com/612749) for details.)
\[2] In Firefox 36 and earlier, the <kbd>Esc</kbd> key returns `"Esc"` instead of `"Escape"`.
\[3] Firefox 36 and earlier reports `"Apps"` instead of `"ContextMenu"` for the context menu key.
\[4] The <kbd>Attn</kbd> key generates the key code `"Unidentified"` on Firefox and Google Chrome, unless the Japanese keyboard layout is in effect, in which case it generates `"KanaMode"` instead.
\[5] The <kbd>Finish</kbd> key generates the key code `"Unidentified"` on Firefox, unless the Japanese keyboard layout is in effect, in which case it generates `"Katakana"` instead.
\[6] Firefox didn't support the `"ZoomIn"` and `"ZoomOut"` keys until Firefox 37.
## Device keys
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"BrightnessDown"</code></td>
<td>
The Brightness Down key. Typically used to reduce the brightness of the
display.
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_MonBrightnessDown</code> (0x1008FF03)<br /><code
>Qt::Key_MonBrightnessDown</code
>
(0x010000B3)
</td>
<td><code>KEYCODE_BRIGHTNESS_DOWN</code> (220)</td>
</tr>
<tr>
<td><code>"BrightnessUp"</code></td>
<td>
The Brightness Up key. Typically increases the brightness of the
display.
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_MonBrightnessUp</code> (0x1008FF02)<br /><code
>Qt::Key_MonBrightnessUp</code
>
(0x010000B2)
</td>
<td><code>KEYCODE_BRIGHTNESS_UP</code> (221)</td>
</tr>
<tr>
<td><code>"Eject"</code></td>
<td>
The <kbd>Eject</kbd> key. Ejects removable media (or toggles an optical
storage device tray open and closed).
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Eject</code> (0x1008FF2C)<br /><code>Qt::Key_Eject</code>
(0x010000B9)
</td>
<td><code>KEYCODE_MEDIA_EJECT</code> (129)</td>
</tr>
<tr>
<td><code>"LogOff"</code> [2]</td>
<td>The <kbd>LogOff</kbd> key.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_LogOff</code> (0x1008FF61)<br /><code
>Qt::Key_LogOff</code
>
(0x010000D9)
</td>
<td></td>
</tr>
<tr>
<td><code>"Power"</code></td>
<td>
The <kbd>Power</kbd> button or key, to toggle power on and off.
<div class="note">
<p>
<strong>Note:</strong> Not all systems pass this key through to the
user agent.
</p>
</div>
</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_POWER</code> (26)</td>
</tr>
<tr>
<td><code>"PowerOff"</code></td>
<td>
The <kbd>PowerOff</kbd> or <kbd>PowerDown</kbd> key. Shuts off the
system.
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_PowerDown</code> (0x1008FF21)<br /><code
>GDK_KEY_PowerOff</code
>
(0x1008FF2A)<br /><code>Qt::Key_PowerDown</code> (0x0100010B)<br /><code
>Qt::Key_PowerOff</code
>
(0x010000B7)
</td>
<td></td>
</tr>
<tr>
<td><code>"PrintScreen"</code></td>
<td>
The <kbd>PrintScreen</kbd> or <kbd>PrtScr</kbd> key. Sometimes
<kbd>SnapShot</kbd>. Captures the screen and prints it or saves it to
disk.
</td>
<td><code>VK_SNAPSHOT</code> (0x2C)</td>
<td></td>
<td>
<code>GDK_KEY_3270_PrintScreen</code> (0xFD1D)<br /><code
>GDK_KEY_Print</code
>
(0xFF61)<br /><code>GDK_KEY_Sys_Req</code> (0xFF15)<br /><code
>Qt::Key_Print</code
>
(0x01000009)<br /><code>Qt::Key_SysReq</code> (0x0100000A)
</td>
<td><code>KEYCODE_SYSRQ</code> (120)</td>
</tr>
<tr>
<td><code>"Hibernate"</code> [2]</td>
<td>
The <kbd>Hibernate</kbd> key. This saves the state of the computer to
disk and then shuts down; the computer can be returned to its previous
state by restoring the saved state information.
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Hibernate</code> (0x1008FFA8)<br /><code
>Qt::Key_Hibernate</code
>
(0x01000108)
</td>
<td></td>
</tr>
<tr>
<td><code>"Standby"</code> [1]</td>
<td>
The <kbd>Standby</kbd> key. (Also known as <kbd>Suspend</kbd> or
<kbd>Sleep</kbd>.) This turns off the display and puts the computer in a
low power consumption mode, without completely powering off.
</td>
<td><code>VK_SLEEP</code> (0x5F)</td>
<td></td>
<td>
<code>GDK_KEY_Standby</code> (0x1008FF10)<br /><code
>GDK_KEY_Suspend</code
>
(0x1008FFA7)<br /><code>GDK_KEY_Sleep</code> (0x1008FF2F)<br /><code
>Qt::Key_Standby</code
>
(0x01000093)<br /><code>Qt::Key_Suspend</code> (0x0100010C)<br /><code
>Qt::Key_Sleep</code
>
(0x01020004)
</td>
<td><code>KEYCODE_SLEEP</code> (223)</td>
</tr>
<tr>
<td><code>"WakeUp"</code> [2]</td>
<td>
The <kbd>WakeUp</kbd> key. Used to wake the computer from the
hibernation or standby modes.
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_WakeUp</code> (0x1008FF2B)<br /><code
>Qt::Key_WakeUp</code
>
(0x010000B8)
</td>
<td><code>KEYCODE_WAKEUP</code> (224)</td>
</tr>
</tbody>
</table>
\[1] The <kbd>Standby</kbd> key is not supported by Firefox 36 and earlier, so it is reported as `"Unidentified"`.
\[2] Prior to Firefox 37, this key generated the value `"Unidentified"`.
## IME and composition keys
Keys used when using an {{glossary("Input Method Editor")}} (IME) to input text which can't readily be entered by simple keypresses, such as text in languages such as those which have more graphemes than there are character entry keys on the keyboard. Common examples include Chinese, Japanese, Korean, and Hindi.
Some keys are common across multiple languages, while others exist only on keyboards targeting specific languages. In addition, not all keyboards have all of these keys.
### Common IME keys
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"AllCandidates"</code></td>
<td>
The <kbd>All Candidates</kbd> key, which starts multi-candidate mode, in
which multiple candidates are displayed for the ongoing input.
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_MultipleCandidate</code> (0xFF3D<br /><code
>Qt::Key_MultipleCandidate</code
>
(0x0100113D)
</td>
<td></td>
</tr>
<tr>
<td><code>"Alphanumeric"</code></td>
<td>The <kbd>Alphanumeric</kbd> key.</td>
<td><code>VK_OEM_ATTN</code> (0xF0)</td>
<td></td>
<td>
<code>GDK_KEY_Eisu_Shift</code> (0xFF2F)<br /><code
>GDK_KEY_Eisu_toggle</code
>
(0xFF30)<br /><code>Qt::Key_Eisu_Shift</code> (0x0100112f)<br /><code
>Qt::Key_Eisu_toggle</code
>
(0x01001130)
</td>
<td></td>
</tr>
<tr>
<td><code>"CodeInput"</code></td>
<td>
The <kbd>Code Input</kbd> key, which enables code input mode, which lets
the user enter characters by typing their code points (their Unicode
character numbers, typically).
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Codeinput</code> (0xFF37)<br /><code
>Qt::Key_Codeinput</code
>
(0x01001137)
</td>
<td></td>
</tr>
<tr>
<td><code>"Compose"</code></td>
<td>The <kbd>Compose</kbd> key.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Multi_key</code> (0xFF20) [1]<br /><code
>Qt::Key_Multi_key</code
>
(0x01001120)
</td>
<td></td>
</tr>
<tr>
<td><code>"Convert"</code> [4]</td>
<td>
The <kbd>Convert</kbd> key, which instructs the IME to convert the
current input method sequence into the resulting character.
</td>
<td><code>VK_CONVERT</code> (0x1C)</td>
<td></td>
<td>
<code>GDK_KEY_Henkan</code> (0xFF23)<br /><code>Qt::Key_Henkan</code>
(0x01001123)
</td>
<td><code>KEYCODE_HENKAN</code> (214)</td>
</tr>
<tr>
<td><code>"Dead"</code></td>
<td>
<p>
A dead "combining" key; that is, a key which is used in tandem with
other keys to generate accented and other modified characters. If
pressed by itself, it doesn't generate a character.
</p>
<p>
If you wish to identify which specific dead key was pressed (in cases
where more than one exists), you can do so by examining the
{{domxref("KeyboardEvent")}}'s associated
{{domxref("Element/compositionupdate_event", "compositionupdate")}} event's
{{domxref("CompositionEvent.data", "data")}} property.
</p>
</td>
<td></td>
<td></td>
<td>See <a href="#dead_keycodes_for_linux">Dead keycodes for Linux</a> below</td>
<td></td>
</tr>
<tr>
<td><code>"FinalMode"</code></td>
<td>
The <kbd>Final</kbd> (Final Mode) key is used on some Asian keyboards to
enter final mode when using IMEs.
</td>
<td><code>VK_FINAL</code> (0x18)</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"GroupFirst"</code></td>
<td>
Switches to the first character group on an
<a href="https://en.wikipedia.org/wiki/ISO/IEC_9995"
>ISO/IEC 9995 keyboard</a
>. Each key may have multiple groups of characters, each in its own
column. Pressing this key instructs the device to interpret keypresses
as coming from the first column on subsequent keystrokes.
</td>
<td></td>
<td></td>
<td><code>GDK_KEY_ISO_First_Group</code> (0xFE0C)</td>
<td></td>
</tr>
<tr>
<td><code>"GroupLast"</code></td>
<td>
Switches to the last character group on an
<a href="https://en.wikipedia.org/wiki/ISO/IEC_9995"
>ISO/IEC 9995 keyboard</a
>.
</td>
<td></td>
<td></td>
<td><code>GDK_KEY_ISO_Last_Group</code> (0xFE0E)</td>
<td></td>
</tr>
<tr>
<td><code>"GroupNext"</code> [4]</td>
<td>
Switches to the next character group on an
<a href="https://en.wikipedia.org/wiki/ISO/IEC_9995"
>ISO/IEC 9995 keyboard</a
>.
</td>
<td></td>
<td></td>
<td><code>GDK_KEY_ISO_Next_Group</code> (0xFE08)</td>
<td><code>KEYCODE_LANGUAGE_SWITCH</code> (204)</td>
</tr>
<tr>
<td><code>"GroupPrevious"</code></td>
<td>
Switches to the previous character group on an
<a href="https://en.wikipedia.org/wiki/ISO/IEC_9995"
>ISO/IEC 9995 keyboard</a
>.
</td>
<td></td>
<td></td>
<td><code>GDK_KEY_ISO_Prev_Group</code> (0xFE0A)</td>
<td></td>
</tr>
<tr>
<td><code>"ModeChange"</code> [5]</td>
<td>The Mode Change key. Toggles or cycles among input modes of IMEs.</td>
<td><code>VK_MODECHANGE</code> (0x1F)</td>
<td></td>
<td>
<code>GDK_KEY_Mode_switch</code> (0xFF7E)<br /><code
>GDK_KEY_script_switch</code
>
(0xFF7E)<br /><code>Qt::Key_Mode_switch</code> (0x0100117E)
</td>
<td><code>KEYCODE_SWITCH_CHARSET</code> (95)</td>
</tr>
<tr>
<td><code>"NextCandidate"</code></td>
<td>
The Next Candidate function key. Selects the next possible match for the
ongoing input.
</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"NonConvert"</code> [2]</td>
<td>
The <kbd>NonConvert</kbd> ("Don't convert") key. This accepts the
current input method sequence without running conversion when using an
IME.
</td>
<td><code>VK_NONCONVERT</code> (0x1D)</td>
<td></td>
<td>
<code>GDK_KEY_Muhenkan</code> (0xFF22)<br /><code
>Qt::Key_Muhenkan</code
>
(0x01001122)<br />
</td>
<td><code>KEYCODE_MUHENKAN</code> (213)</td>
</tr>
<tr>
<td><code>"PreviousCandidate"</code></td>
<td>
The Previous Candidate key. Selects the previous possible match for the
ongoing input.
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_PreviousCandidate</code> (0xFF3E)<br /><code
>Qt::Key_PreviousCandidate</code
>
(0x0100113E)
</td>
<td></td>
</tr>
<tr>
<td><code>"Process"</code> [3]</td>
<td>
The <kbd>Process</kbd> key. Instructs the IME to process the conversion.
</td>
<td><code>VK_PROCESSKEY</code> (0xE5)</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"SingleCandidate"</code> [4]</td>
<td>
The Single Candidate key. Enables single candidate mode (as opposed to
multi-candidate mode); in this mode, only one candidate is displayed at
a time.
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_SingleCandidate</code> (0xFF3C)<br /><code
>Qt::Key_SingleCandidate</code
>
(0x0100113C)
</td>
<td></td>
</tr>
</tbody>
</table>
\[1] On the _X Window System_, the <kbd>Compose</kbd> key is called the <kbd>Multi</kbd> key.
\[2] The <kbd>NonConvert</kbd> key is reported as `"Nonconvert"` instead of the correct `"NonConvert"` by Firefox versions 36 and earlier.
\[3] The <kbd>Process</kbd> key currently returns `"Unidentified"` in Firefox. Google Chrome returns the value of the key as if IME were not in use.
\[4] Prior to Firefox 37, these keys were `"Unidentified"`.
\[5] Firefox generates the key value `"AltGraph"` instead of `"ModeChange"`.
### Korean keyboards only
These keys are only available on Korean keyboards. There are other keys defined by various platforms for Korean keyboards, but these are the most common and are the ones identified by the UI Events specification.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"HangulMode"</code></td>
<td>
The <kbd>Hangul</kbd> (Korean character set) mode key, which toggles
between Hangul and English entry modes.
</td>
<td><code>VK_HANGUL</code> (0x15) [1]</td>
<td></td>
<td>
<code>GDK_KEY_Hangul</code> (0xFF31)<br /><code>Qt::Key_Hangul</code>
(0x01001131)
</td>
<td></td>
</tr>
<tr>
<td><code>"HanjaMode"</code></td>
<td>
Selects the Hanja mode, for converting Hangul characters to the more
specific Hanja characters.
</td>
<td><code>VK_HANJA</code> (0x19) [1]</td>
<td></td>
<td>
<code>GDK_KEY_Hangul_Hanja</code> (0xFF34)<br /><code
>Qt::Key_Hangul_Hanja</code
>
(0x01001134)
</td>
<td></td>
</tr>
<tr>
<td><code>"JunjaMode"</code></td>
<td>
Selects the Junja mode, in which Korean is represented using single-byte
Latin characters.
</td>
<td><code>VK_JUNJA</code> (0x17)</td>
<td></td>
<td>
<code>GDK_KEY_Hangul_Jeonja</code> (0xFF38)<br /><code
>Qt::Key_Hangul_Jeonja</code
>
(0x01001138)
</td>
<td></td>
</tr>
</tbody>
</table>
\[1] `VK_HANGUL` and `VK_KANA` share the same numeric key value on Windows, as do `VK_HANJA` and `VK_KANJI`.
### Japanese keyboards only
These keys are only available on Japanese keyboards.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"Eisu"</code> [1]</td>
<td>
The <kbd>Eisu</kbd> key. This key's purpose is defined by the IME, but
may be used to close the IME.
</td>
<td></td>
<td><code>kVK_JIS_Eisu</code> (0x66)</td>
<td>
<code>GDK_KEY_Eisu_toggle</code> (0xFF2F)<br /><code
>Qt::Key_Eisu_toggle</code
>
(0x01001130)
</td>
<td><code>KEYCODE_EISU</code> (212)</td>
</tr>
<tr>
<td><code>"Hankaku"</code> [3]</td>
<td>The <kbd>Hankaku</kbd> (half-width characters) key.</td>
<td><code>VK_OEM_AUTO</code> (0xF3)</td>
<td></td>
<td>
<code>GDK_KEY_Hankaku</code> (0xFF29)<br /><code>Qt::Key_Hankaku</code>
(0x01001129)
</td>
<td></td>
</tr>
<tr>
<td><code>"Hiragana"</code></td>
<td>The <kbd>Hiragana</kbd> key; selects Kana characters mode.</td>
<td><code>VK_OEM_COPY</code> (0xF2)</td>
<td></td>
<td>
<code>GDK_KEY_Hiragana</code> (0xFF25)<br /><code
>Qt::Key_Hiragana</code
>
(0x01001125)
</td>
<td></td>
</tr>
<tr>
<td><code>"HiraganaKatakana"</code> [6]</td>
<td>Toggles between the Hiragana and Katakana writing systems.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Hiragana_Katakana</code> (0xFF27)<br /><code
>Qt::Key_Hiragana_Katakana</code
>
(0x01001127)
</td>
<td><code>KEYCODE_KATAKANA_HIRAGANA</code> (215)</td>
</tr>
<tr>
<td><code>"KanaMode"</code></td>
<td>The <kbd>Kana Mode</kbd> (Kana Lock) key.</td>
<td><code>VK_KANA</code> (0x15) [2]<br /><code>VK_ATTN</code> (0xF6)</td>
<td></td>
<td>
<code>GDK_KEY_Kana_Lock</code> (0xFF2D)<br /><code
>GDK_KEY_Kana_Shift</code
>
(0xFF2E)<br /><code>Qt::Key_Kana_Lock</code> (0x0100112D)<br /><code
>Qt::Key_Kana_Shift</code
>
(0x0100112E)
</td>
<td></td>
</tr>
<tr>
<td><code>"KanjiMode"</code></td>
<td>
The <kbd>Kanji Mode</kbd> key. Enables entering Japanese text using the
ideographic characters of Chinese origin.
</td>
<td><code>VK_KANJI</code> [2]</td>
<td><code>kVK_JIS_Kana</code> (0x68)</td>
<td>
<code>GDK_KEY_Kanji</code> (0xFF21)<br /><code>Qt::Key_Kanji</code>
(0x01001121)
</td>
<td><code>KEYCODE_KANA</code> (218)</td>
</tr>
<tr>
<td><code>"Katakana"</code></td>
<td>The <kbd>Katakana</kbd> key.</td>
<td><code>VK_OEM_FINISH</code> (0xF1)</td>
<td></td>
<td>
<code>GDK_KEY_Katakana</code> (0xFF26)<br /><code
>Qt::Key_Katakana</code
>
(0x01001126)
</td>
<td></td>
</tr>
<tr>
<td><code>"Romaji"</code> [5]</td>
<td>The <kbd>Romaji</kbd> key; selects the Roman character set.</td>
<td><code>VK_OEM_BACKTAB</code> (0xF5)</td>
<td></td>
<td>
<code>GDK_KEY_Romaji</code> (0xFF24)<br /><code>Qt::Key_Romaji</code>
(0x01001124)
</td>
<td></td>
</tr>
<tr>
<td><code>"Zenkaku"</code> [4]</td>
<td>The <kbd>Zenkaku</kbd> (full width) characters key.</td>
<td><code>VK_OEM_ENLW</code> (0xF4)</td>
<td></td>
<td>
<code>GDK_KEY_Zenkaku</code> (0xFF28)<br /><code>Qt::Key_Zenkaku</code>
(0x01001128)
</td>
<td></td>
</tr>
<tr>
<td><code>"ZenkakuHanaku"</code> [6]</td>
<td>
The <kbd>Zenkaku/Hankaku</kbd> (full width/half width) toggle key.
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Zenkaku_Hankaku</code> (0xFF2A)<br /><code
>Qt::Zenkaku_Hankaku</code
>
(0x0100112A)
</td>
<td>
<p><code>KEYCODE_ZENKAKU_HANKAKU</code> (211)</p>
</td>
</tr>
</tbody>
</table>
\[1] Prior to Firefox 37, the <kbd>Eisu</kbd> key was mapped to `"RomanCharacters"` by mistake.
\[2] `VK_HANGUL` and `VK_KANA` share the same numeric key value on Windows, as do `VK_HANJA` and `VK_KANJI`.
\[3] Prior to Firefox 37, the <kbd>Hankaku</kbd> (half-width) key generated the key value `"HalfWidth"` on Firefox.
\[4] Firefox 36 and earlier identifies this key as `"FullWidth"` on Japanese keyboard layouts and `"Unidentified"` on all other keyboard layouts. Firefox 37 and later, and all versions of Google Chrome, correctly return `"Zenkaku"`.
\[5] Firefox 36 and earlier identifies the <kbd>Romaji</kbd> key as `"RomanCharacters"` on Japanese keyboards and `"Unidentified"` for other keyboards; this is corrected to return `"Romaji"` in Firefox 37 and later.
\[6] This key is reported as `"Unidentified"` prior to Firefox 37.
### Dead keycodes for Linux
Linux generates accented characters using special **dead keys**. _Dead keys_ are keys which are pressed in combination with character keys to generate accented forms of those characters. You can identify which specific dead key was used (if more than one exists) by examining the {{domxref("KeyboardEvent")}}'s associated {{domxref("Element/compositionupdate_event", "compositionupdate")}} event's {{domxref("CompositionEvent.data", "data")}} property.
You can find a table of the dead keys and the characters they can be used with to generate accented or otherwise special characters on Linux using GTK.
The value of {{domxref("CompositionEvent.data", "data")}} will be one of the following:
<table class="no-markdown">
<thead>
<tr>
<th scope="col">
<strong><code>CompositionEvent.data</code></strong> value
</th>
<th scope="col">Symbol</th>
<th scope="col">Comments</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>GDK_KEY_dead_grave</code> (0xFE50)<br /><code
>Qt::Key_Dead_Grave</code
>
(0x01001250)
</td>
<td>`</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_acute</code> (0xFE51)<br /><code
>Qt::Key_Dead_Acute</code
>
(0x01001251)
</td>
<td>´</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_circumflex</code> (0xFE52)<br /><code
>Qt::Key_Dead_Circumflex</code
>
(0x01001252)
</td>
<td>ˆ</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_tilde</code> (0xFE53)<br /><code
>Qt::Key_Dead_Tilde</code
>
(0x01001253)
</td>
<td>˜</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_perispomeni</code> (0xFE53)</td>
<td> ͂</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_macron</code> (0xFE54)<br /><code
>Qt::Key_Dead_Macron</code
>
(0x01001254)
</td>
<td>¯</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_breve</code> (0xFE55)<br /><code
>Qt::Key_Dead_Breve</code
>
(0x01001255)
</td>
<td>˘</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_abovedot</code> (0xFE56)<br /><code
>Qt::Key_Dead_Abovedot</code
>
(0x01001256)
</td>
<td>˙</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_diaeresis</code> (0xFE57)<br /><code
>Qt::Key_Dead_Diaeresis</code
>
(0x01001257)
</td>
<td>¨</td>
<td>Also called an umlaut.</td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_abovering</code> (0xFE58)<br /><code
>Qt::Key_Dead_Abovering</code
>
(0x01001258)
</td>
<td>˚</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_doubleacute</code> (0xFE59)<br /><code
>Qt::Key_Dead_Doubleacute</code
>
(0x01001259)
</td>
<td>˝</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_caron</code> (0xFE5A)<br /><code
>Qt::Key_Dead_Caron</code
>
(0x0100125A)
</td>
<td>ˇ</td>
<td>Also called a háček; used in Czech among other languages.</td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_cedilla</code> (0xFE5B)<br /><code
>Qt::Key_Dead_Cedilla</code
>
(0x0100125B)
</td>
<td>¸</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_ogonek</code> (0xFE5C)<br /><code
>Qt::Key_Dead_Ogonek</code
>
(0x0100125C)
</td>
<td>˛</td>
<td>Also called a nosinė; used in Polish and Old Irish.</td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_iota</code> (0xFE5D)<br /><code
>Qt::Key_Dead_Iota</code
>
(0x0100125D)
</td>
<td> ͅ</td>
<td>Iota subscript.</td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_voiced_sound</code> (0xFE5E)<br /><code
>Qt::Key_Dead_Voiced_Sound</code
>
(0x0100125E)
</td>
<td>゙</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_semivoiced_sound</code> (0xFE5F)<br /><code
>Qt::Key_Dead_Semivoiced_Sound</code
>
(0x0100125F)
</td>
<td>゚</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_belowdot</code> (0xFE60)<br /><code
>Qt::Key_Dead_Belowdot</code
>
(0x01001260)
</td>
<td>̣̣</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_hook</code> (0xFE61)<br /><code
>Qt::Key_Dead_Hook</code
>
(0x01001261)
</td>
<td> ̡</td>
<td></td>
</tr>
<tr>
<td>
<code>GDK_KEY_dead_horn</code> (0xFE62)<br /><code
>Qt::Key_Dead_Horn</code
>
(0x01001262)
</td>
<td> ̛</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_stroke</code> (0xFE63)</td>
<td> ̶̶</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_abovecomma</code> (0xFE64)</td>
<td> ̓̓</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_psili</code> (0xFE64)</td>
<td> ᾿</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_abovereversedcomma</code> (0xFE65)</td>
<td>ʽ</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_dasia</code> (0xFE65)</td>
<td>῾</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_doublegrave</code> (0xFE66)</td>
<td> ̏</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_belowring</code> (0xFE67)</td>
<td>˳</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_belowmacron</code> (0xFE68)</td>
<td> ̱</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_belowcircumflex</code> (0xFE69)</td>
<td>ꞈ</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_belowtilde</code> (0xFE6A)</td>
<td>̰</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_belowbreve</code> (0xFE6B)</td>
<td>̮</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_belowdiaeresis</code> (0xFE6C)</td>
<td> ̤</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_invertedbreve</code> (0xFE6D)</td>
<td>̯</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_belowcomma</code> (0xFE6E)</td>
<td>̦</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_currency</code> (0xFE6F)</td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_a</code> (0xFE80)</td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_A</code> (0xFE81)</td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_e</code> (0xFE82)</td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_E</code> (0xFE83)</td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_i</code> (0xFE84)</td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_I</code> (0xFE85)</td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_o</code> (0xFE86)</td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_O</code> (0xFE87)</td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_u</code> (0xFE88)</td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_U</code> (0xFE89)</td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_small_schwa</code> (0xFE8A)</td>
<td>ə</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_capital_schwa</code> (0xFE8B)</td>
<td>Ə</td>
<td></td>
</tr>
<tr>
<td><code>GDK_KEY_dead_greek</code> (0xFE8C)</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
## Function keys
While various platforms support different numbers of the general-purpose function keys, such as <kbd>F1</kbd>–<kbd>F12</kbd> (or <kbd>F1</kbd>–<kbd>F10</kbd>, or <kbd>F1</kbd>–<kbd>F15</kbd>, etc.), the first few are specifically defined as follows.
If more function keys are available, their names continue the pattern here by continuing to increment the numeric portion of each key's name, so that, for example, `"F24"` is a valid key value.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"F1"</code></td>
<td>The first general-purpose function key, <kbd>F1</kbd>.</td>
<td><code>VK_F1</code> (0x70)</td>
<td><code>kVK_F1</code> (0x7A)</td>
<td>
<code>GDK_KEY_F1</code> (0xFFBE)<br /><code>GDK_KEY_KP_F1</code>
(0xFF91)<br /><code>Qt::Key_F1</code> (0x01000030)
</td>
<td><code>KEYCODE_F1</code> (131)</td>
</tr>
<tr>
<td><code>"F2"</code></td>
<td>The <kbd>F2</kbd> key.</td>
<td><code>VK_F2</code> (0x71)</td>
<td><code>kVK_F2</code> (0x78)</td>
<td>
<code>GDK_KEY_F2</code> (0xFFBF)<br /><code>GDK_KEY_KP_F2</code>
(0xFF92)<br /><code>Qt::Key_F2</code> (0x01000031)
</td>
<td><code>KEYCODE_F2</code> (132)</td>
</tr>
<tr>
<td><code>"F3"</code></td>
<td>The <kbd>F3</kbd> key.</td>
<td><code>VK_F3</code> (0x72)</td>
<td><code>kVK_F3</code> (0x63)</td>
<td>
<code>GDK_KEY_F3</code> (0xFFC0)<br /><code>GDK_KEY_KP_F3</code>
(0xFF93)<br /><code>Qt::Key_F3</code> (0x01000032)
</td>
<td><code>KEYCODE_F3</code> (133)</td>
</tr>
<tr>
<td><code>"F4"</code></td>
<td>The <kbd>F4</kbd> key.</td>
<td><code>VK_F4</code> (0x73)</td>
<td><code>kVK_F4</code> (0x76)</td>
<td>
<code>GDK_KEY_F4</code> (0xFFC1)<br /><code>GDK_KEY_KP_F4</code>
(0xFF94)<br /><code>Qt::Key_F4</code> (0x01000033)
</td>
<td><code>KEYCODE_F4</code> (134)</td>
</tr>
<tr>
<td><code>"F5"</code></td>
<td>The <kbd>F5</kbd> key.</td>
<td><code>VK_F5</code> (0x74)</td>
<td><code>kVK_F5</code> (0x60)</td>
<td>
<code>GDK_KEY_F5</code> (0xFFC2)<br /><code>Qt::Key_F5</code>
(0x01000034)
</td>
<td><code>KEYCODE_F5</code> (135)</td>
</tr>
<tr>
<td><code>"F6"</code></td>
<td>The <kbd>F6</kbd> key.</td>
<td><code>VK_F6</code> (0x75)</td>
<td><code>kVK_F6</code> (0x61)</td>
<td>
<code>GDK_KEY_F6</code> (0xFFC3)<br /><code>Qt::Key_F6</code>
(0x01000035)
</td>
<td><code>KEYCODE_F6</code> (136)</td>
</tr>
<tr>
<td><code>"F7"</code></td>
<td>The <kbd>F7</kbd> key.</td>
<td><code>VK_F7</code> (0x76)</td>
<td><code>kVK_F7</code> (0x62)</td>
<td>
<code>GDK_KEY_F7</code> (0xFFC4)<br /><code>Qt::Key_F7</code>
(0x01000036)
</td>
<td><code>KEYCODE_F7</code> (137)</td>
</tr>
<tr>
<td><code>"F8"</code></td>
<td>The <kbd>F8</kbd> key.</td>
<td><code>VK_F8</code> (0x77)</td>
<td><code>kVK_F8</code> (0x64)</td>
<td>
<code>GDK_KEY_F8</code> (0xFFC5)<br /><code>Qt::Key_F8</code>
(0x01000037)
</td>
<td><code>KEYCODE_F8</code> (138)</td>
</tr>
<tr>
<td><code>"F9"</code></td>
<td>The <kbd>F9</kbd> key.</td>
<td><code>VK_F9</code> (0x78)</td>
<td><code>kVK_F9</code> (0x65)</td>
<td>
<code>GDK_KEY_F9</code> (0xFFC6)<br /><code>Qt::Key_F9</code>
(0x01000038)
</td>
<td><code>KEYCODE_F9</code> (139)</td>
</tr>
<tr>
<td><code>"F10"</code></td>
<td>The <kbd>F10</kbd> key.</td>
<td><code>VK_F10</code> (0x79)</td>
<td><code>kVK_F10</code> (0x6D)</td>
<td>
<code>GDK_KEY_F10</code> (0xFFC7)<br /><code>Qt::Key_F10</code>
(0x01000039)
</td>
<td><code>KEYCODE_F10</code> (140)</td>
</tr>
<tr>
<td><code>"F11"</code></td>
<td>The <kbd>F11</kbd> key.</td>
<td><code>VK_F11</code> (0x7A)</td>
<td><code>kVK_F11</code> (0x67)</td>
<td>
<code>GDK_KEY_F11</code> (0xFFC8)<br /><code>Qt::Key_F11</code>
(0x0100003A)
</td>
<td><code>KEYCODE_F11</code> (141)</td>
</tr>
<tr>
<td><code>"F12"</code></td>
<td>The <kbd>F12</kbd> key.</td>
<td><code>VK_F12</code> (0x7B)</td>
<td><code>kVK_F12</code> (0x6F)</td>
<td>
<code>GDK_KEY_F12</code> (0xFFC9)<br /><code>Qt::Key_F12</code>
(0x0100003B)
</td>
<td><code>KEYCODE_F12</code> (142)</td>
</tr>
<tr>
<td><code>"F13"</code></td>
<td>The <kbd>F13</kbd> key.</td>
<td><code>VK_F13</code> (0x7C)</td>
<td><code>kVK_F13</code> (0x69)</td>
<td>
<code>GDK_KEY_F13</code> (0xFFCA)<br /><code>Qt::Key_F13</code>
(0x0100003C)
</td>
<td><code>KEYCODE_F13</code></td>
</tr>
<tr>
<td><code>"F14"</code></td>
<td>The <kbd>F14</kbd> key.</td>
<td><code>VK_F14</code> (0x7D)</td>
<td><code>kVK_F14</code> (0x6B)</td>
<td>
<code>GDK_KEY_F14</code> (0xFFCB)<br /><code>Qt::Key_F1</code>4
(0x0100003D)
</td>
<td><code>KEYCODE_F14</code></td>
</tr>
<tr>
<td><code>"F15"</code></td>
<td>The <kbd>F15</kbd> key.</td>
<td><code>VK_F15</code> (0x7E)</td>
<td><code>kVK_F15</code> (0x71)</td>
<td>
<code>GDK_KEY_F15</code> (0xFFCC)<br /><code>Qt::Key_F1</code>5
(0x0100003E)
</td>
<td><code>KEYCODE_F15</code></td>
</tr>
<tr>
<td><code>"F16"</code></td>
<td>The <kbd>F16</kbd> key.</td>
<td><code>VK_F16</code> (0x7F)</td>
<td><code>kVK_F16</code> (0x6A)</td>
<td>
<code>GDK_KEY_F16</code> (0xFFCD)<br /><code>Qt::Key_F1</code>6
(0x0100003F)
</td>
<td><code>KEYCODE_F16</code></td>
</tr>
<tr>
<td><code>"F17"</code></td>
<td>The <kbd>F17</kbd> key.</td>
<td><code>VK_F17</code> (0x80)</td>
<td><code>kVK_F17</code> (0x40)</td>
<td>
<code>GDK_KEY_F17</code> (0xFFCE)<br /><code>Qt::Key_F1</code>7
(0x01000040)
</td>
<td><code>KEYCODE_F17</code></td>
</tr>
<tr>
<td><code>"F18"</code></td>
<td>The <kbd>F18</kbd> key.</td>
<td><code>VK_F18</code> (0x81)</td>
<td><code>kVK_F18</code> (0x4F)</td>
<td>
<code>GDK_KEY_F18</code> (0xFFCF)<br /><code>Qt::Key_F1</code>8
(0x01000041)
</td>
<td><code>KEYCODE_F18</code></td>
</tr>
<tr>
<td><code>"F19"</code></td>
<td>The <kbd>F19</kbd> key.</td>
<td><code>VK_F19</code> (0x82)</td>
<td><code>kVK_F19</code> (0x50)</td>
<td>
<code>GDK_KEY_F19</code> (0xFFD0)<br /><code>Qt::Key_F1</code>9
(0x01000042)
</td>
<td><code>KEYCODE_F19</code></td>
</tr>
<tr>
<td><code>"F20"</code></td>
<td>The <kbd>F20</kbd> key.</td>
<td><code>VK_F20</code> (0x83)</td>
<td><code>kVK_F20</code> (0x5A)</td>
<td>
<code>GDK_KEY_F20</code> (0xFFD1)<br /><code>Qt::Key_F20</code>
(0x01000043)
</td>
<td><code>KEYCODE_F20</code></td>
</tr>
<tr>
<td><code>"Soft1"</code></td>
<td>The first general-purpose virtual function key.</td>
<td></td>
<td></td>
<td><code>Qt::Key_Context1</code> (0x01100000)</td>
<td></td>
</tr>
<tr>
<td><code>"Soft2"</code></td>
<td>The second general-purpose virtual function key.</td>
<td></td>
<td></td>
<td><code>Qt::Key_Context2</code> (0x01100001)</td>
<td></td>
</tr>
<tr>
<td><code>"Soft3"</code></td>
<td>The third general-purpose virtual function key.</td>
<td></td>
<td></td>
<td><code>Qt::Key_Context3</code> (0x01100002)</td>
<td></td>
</tr>
<tr>
<td><code>"Soft4"</code></td>
<td>The fourth general-purpose virtual function key.</td>
<td></td>
<td></td>
<td><code>Qt::Key_Context4</code> (0x01100003)</td>
<td></td>
</tr>
</tbody>
</table>
## Phone keys
These keys represent buttons which commonly exist on modern smartphones.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"AppSwitch"</code></td>
<td>
Presents a list of recently-used applications which lets the user change
apps quickly.
</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_APP_SWITCH</code> (181)</td>
</tr>
<tr>
<td><code>"Call"</code></td>
<td>The <kbd>Call</kbd> key. Dials the number which has been entered.</td>
<td></td>
<td></td>
<td><code>Qt::Key_Call</code> (0x01100004)</td>
<td><code>KEYCODE_CALL</code> (5)</td>
</tr>
<tr>
<td><code>"Camera"</code></td>
<td>The <kbd>Camera</kbd> key. Activates the camera.</td>
<td></td>
<td></td>
<td><code>Qt::Key_Camera</code> (0x01100020)</td>
<td><code>KEYCODE_CAMERA</code> (27)</td>
</tr>
<tr>
<td><code>"CameraFocus"</code></td>
<td>The <kbd>Focus</kbd> key. Focuses the camera.</td>
<td></td>
<td></td>
<td><code>Qt::Key_CameraFocus</code> (0x01100021)</td>
<td><code>KEYCODE_FOCUS</code> (80)</td>
</tr>
<tr>
<td><code>"EndCall"</code></td>
<td>The <kbd>End Call</kbd> or <kbd>Hang Up</kbd> button.</td>
<td></td>
<td></td>
<td><code>Qt::Key_Hangup</code> (0x01100005)</td>
<td><code>KEYCODE_ENDCALL</code> (6)</td>
</tr>
<tr>
<td><code>"GoBack"</code></td>
<td>The <kbd>Back</kbd> button.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_BACK</code> (4)</td>
</tr>
<tr>
<td><code>"GoHome"</code> [1]</td>
<td>
The <kbd>Home</kbd> button. Returns the user to the phone's main screen
(usually an application launcher).
</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_HOME</code> (3)</td>
</tr>
<tr>
<td><code>"HeadsetHook"</code></td>
<td>
The <kbd>Headset Hook</kbd> key. This is typically actually a button on
the headset which is used to hang up calls and play or pause media.
</td>
<td></td>
<td></td>
<td><code>Qt::Key_ToggleCallHangup</code> (0x01100007)</td>
<td><code>KEYCODE_HEADSETHOOK</code> (79)</td>
</tr>
<tr>
<td><code>"LastNumberRedial"</code></td>
<td>The <kbd>Redial</kbd> button. Redials the last-called number.</td>
<td></td>
<td></td>
<td><code>Qt::Key_LastNumberRedial</code> (0x01100009)</td>
<td></td>
</tr>
<tr>
<td><code>"Notification"</code></td>
<td>The <kbd>Notification</kbd> key.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_NOTIFICATION</code> (83)</td>
</tr>
<tr>
<td><code>"MannerMode"</code></td>
<td>
A button which cycles among the notification modes: silent, vibrate,
ring, and so forth.
</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_MANNER_MODE</code> (205)</td>
</tr>
<tr>
<td><code>"VoiceDial"</code></td>
<td>The <kbd>Voice Dial</kbd> key. Initiates voice dialing.</td>
<td></td>
<td></td>
<td><code>Qt::Key_VoiceDial</code> (0x01100008)</td>
<td><code>KEYCODE_VOICE_ASSIST</code> (231)</td>
</tr>
</tbody>
</table>
\[1] Prior to Firefox 37, the Home button generated a key code of `"Exit"`. Starting in Firefox 37, the button generates the key code `"MozHomeScreen"`.
## Multimedia keys
The multimedia keys are extra buttons or keys for controlling media devices, found on some keyboards.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"ChannelDown"</code></td>
<td>Switches to the previous channel.</td>
<td><code>APPCOMMAND_MEDIA_CHANNEL_DOWN</code></td>
<td></td>
<td><code>Qt::Key_ChannelDown</code> (0x01000119)</td>
<td><code>KEYCODE_CHANNEL_DOWN</code> (167)</td>
</tr>
<tr>
<td><code>"ChannelUp"</code></td>
<td>Switches to the next channel.</td>
<td><code>APPCOMMAND_MEDIA_CHANNEL_UP</code></td>
<td></td>
<td><code>Qt::Key_ChannelUp</code> (0x01000118)</td>
<td><code>KEYCODE_CHANNEL_UP</code> (166)</td>
</tr>
<tr>
<td><code>"MediaFastForward"</code> [2]</td>
<td>
Starts, continues, or increases the speed of fast forwarding the media.
</td>
<td><code>APPCOMMAND_MEDIA_FAST_FORWARD</code></td>
<td></td>
<td>
<code>GDK_KEY_AudioForward (0x1008FF97)<br />Qt:Key_AudioForward</code>
(0x01000102)
</td>
<td><code>KEYCODE_MEDIA_FAST_FORWARD</code> (90)</td>
</tr>
<tr>
<td><code>"MediaPause"</code></td>
<td>
<p>Pauses the currently playing media.</p>
<div class="notecard note">
<p>
<strong>Note:</strong> Some older applications use
<code>"Pause"</code>, but this is not correct.
</p>
</div>
</td>
<td><code>APPCOMMAND_MEDIA_PAUSE</code></td>
<td></td>
<td>
<code>GDK_KEY_AudioPause</code> (0x1008FF31)<br /><code
>Qt::Key_MediaPause</code
>
(0x1000085)
</td>
<td><code>KEYCODE_MEDIA_PAUSE</code> (127)</td>
</tr>
<tr>
<td><code>"MediaPlay"</code></td>
<td>
Starts or continues playing media at normal speed, if not already doing
so. Has no effect otherwise.
</td>
<td><code>APPCOMMAND_MEDIA_PLAY</code></td>
<td></td>
<td><code>GDK_KEY_AudioPlay</code> (0x1008FF14)</td>
<td><code>KEYCODE_MEDIA_PLAY</code><code> (126)</code></td>
</tr>
<tr>
<td><code>"MediaPlayPause"</code></td>
<td>Toggles between playing and pausing the current media.</td>
<td>
<code>VK_MEDIA_PLAY_PAUSE</code> (0xB3)<br /><code
>APPCOMMAND_MEDIA_PLAY_PAUSE</code
>
</td>
<td></td>
<td><code>Qt::Key_MediaTogglePlayPause</code> (0x1000086)</td>
<td><code>KEYCODE_MEDIA_PLAY_PAUSE</code> (85)</td>
</tr>
<tr>
<td><code>"MediaRecord"</code></td>
<td>Starts or resumes recording media.</td>
<td><code>APPCOMMAND_MEDIA_RECORD</code></td>
<td></td>
<td>
<code>GDK_KEY_AudioRecord</code> (0x1008FF1C)<br /><code
>Qt::Key_MediaRecord</code
>
(0x01000084)
</td>
<td><code>KEYCODE_MEDIA_RECORD</code><code> (130)</code></td>
</tr>
<tr>
<td><code>"MediaRewind"</code></td>
<td>Starts, continues, or increases the speed of rewinding the media.</td>
<td><code>APPCOMMAND_MEDIA_REWIND</code></td>
<td></td>
<td>
<code>GDK_KEY_AudioRewind</code> (0x1008FF3E)<br /><code
>Qt::Key_AudioRewind</code
>
(0x010000C5)
</td>
<td><code>KEYCODE_MEDIA_REWIND</code><code> (89)</code></td>
</tr>
<tr>
<td><code>"MediaStop"</code></td>
<td>
Stops the current media activity (such as playing, recording, pausing,
forwarding, or rewinding). Has no effect if the media is currently
stopped already.
</td>
<td>
<code>VK_MEDIA_STOP</code> (0xB2)<br /><code
>APPCOMMAND_MEDIA_STOP</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_AudioStop</code> (0x1008FF15)<br /><code
>Qt::Key_MediaStop</code
>
(0x01000081)
</td>
<td><code>KEYCODE_MEDIA_STOP</code> (86)</td>
</tr>
<tr>
<td><code>"MediaTrackNext"</code> [1]</td>
<td>Seeks to the next media or program track.</td>
<td>
<code>VK_MEDIA_NEXT_TRACK</code> (0xB0)<br /><code
>APPCOMMAND_MEDIA_NEXTTRACK</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_AudioNext</code> (0x1008FF17)<br /><code
>Qt::Key_MediaNext</code
>
(0x01000083)
</td>
<td><code>KEYCODE_MEDIA_NEXT</code> (87)</td>
</tr>
<tr>
<td><code>"MediaTrackPrevious"</code> [1]</td>
<td>Seeks to the previous media or program track.</td>
<td>
<code>VK_MEDIA_PREV_TRACK</code> (0xB1)<br /><code
>APPCOMMAND_MEDIA_PREVIOUSTRACK</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_AudioPrev</code> (0x1008FF16)<br /><code
>Qt::Key_MediaPrevious</code
>
(0x01000082)
</td>
<td><code>KEYCODE_MEDIA_PREVIOUS</code> (88)</td>
</tr>
</tbody>
</table>
\[1] Legacy Edge and Firefox (36 and earlier) use `"MediaNextTrack"` and `"MediaPreviousTrack"` instead of `"MediaTrackNext"` and `"MediaTrackPrevious"`.
\[2] Prior to Firefox 37, Firefox generated the key code `"FastFwd"` on some platforms and `"Unidentified"` on others instead of `"MediaFastForward"`.
## Audio control keys
These media keys are used specifically for controlling audio.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"AudioBalanceLeft"</code></td>
<td>Adjusts audio balance toward the left.</td>
<td><code>VK_AUDIO_BALANCE_LEFT</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"AudioBalanceRight"</code></td>
<td>Adjusts audio balance toward the right.</td>
<td><code>VK_AUDIO_BALANCE_RIGHT</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"AudioBassDown"</code></td>
<td>Decreases the amount of bass.</td>
<td><code>APPCOMMAND_BASS_DOWN</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"AudioBassBoostDown"</code></td>
<td>
Reduces bass boosting or cycles downward through bass boost modes or
states.
</td>
<td><code>VK_BASS_BOOST_DOWN</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"AudioBassBoostToggle"</code></td>
<td>Toggles bass boosting on and off.</td>
<td><code>APPCOMMAND_BASS_BOOST</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"AudioBassBoostUp"</code></td>
<td>
Increases the amount of bass boosting, or cycles upward through a set of
bass boost modes or states.
</td>
<td><code>VK_BASS_BOOST_UP</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"AudioBassUp"</code></td>
<td>Increases the amount of bass.</td>
<td><code>APPCOMMAND_BASS_UP</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"AudioFaderFront"</code></td>
<td>Adjusts the audio fader toward the front.</td>
<td><code>VK_FADER_FRONT</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"AudioFaderRear"</code></td>
<td>Adjusts the audio fader toward the rear.</td>
<td><code>VK_FADER_REAR</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"AudioSurroundModeNext"</code></td>
<td>Selects the next available surround sound mode.</td>
<td><code>VK_SURROUND_MODE_NEXT</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"AudioTrebleDown"</code></td>
<td>Decreases the amount of treble.</td>
<td><code>APPCOMMAND_TREBLE_DOWN</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"AudioTrebleUp"</code></td>
<td>Increases the amount of treble.</td>
<td><code>APPCOMMAND_TREBLE_UP</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"AudioVolumeDown" [1]</code></td>
<td>Decreases the audio volume.</td>
<td>
<code>VK_VOLUME_DOWN</code> (0xAE)<br /><code
>APPCOMMAND_VOLUME_DOWN</code
>
</td>
<td><code>kVK_VolumeDown</code> (0x49)</td>
<td>
<code>GDK_KEY_AudioLowerVolume</code> (0x1008FF11)<br /><code
>Qt::Key_VolumeDown</code
>
(0x01000070)
</td>
<td><code>KEYCODE_VOLUME_DOWN</code> (25)</td>
</tr>
<tr>
<td><code>"AudioVolumeMute" [1]</code></td>
<td>Mutes the audio.</td>
<td>
<code>VK_VOLUME_MUTE</code> (0xAD)<br /><code
>APPCOMMAND_VOLUME_MUTE</code
>
</td>
<td><code>kVK_Mute</code> (0x4A)</td>
<td>
<code>GDK_KEY_AudioMute</code> (0x1008FF12)<br /><code
>Qt::Key_VolumeMute</code
>
(0x01000071)
</td>
<td><code>KEYCODE_VOLUME_MUTE</code> (164)</td>
</tr>
<tr>
<td><code>"AudioVolumeUp" [1]</code></td>
<td>Increases the audio volume.</td>
<td>
<code>VK_VOLUME_UP</code> (0xAF)<br /><code>APPCOMMAND_VOLUME_UP</code>
</td>
<td><code>kVK_VolumeUp</code> (0x48)</td>
<td>
<code>GDK_KEY_AudioRaiseVolume</code> (0x1008FF13)<br /><code
>Qt::Key_VolumeUp</code
>
(0x01000072)
</td>
<td><code>KEYCODE_VOLUME_UP</code> (24)</td>
</tr>
<tr>
<td><code>"MicrophoneToggle"</code></td>
<td>Toggles the microphone on and off.</td>
<td><code>APPCOMMAND_MIC_ON_OFF_TOGGLE</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"MicrophoneVolumeDown"</code></td>
<td>Decreases the microphone's input volume.</td>
<td><code>APPCOMMAND_MICROPHONE_VOLUME_DOWN</code></td>
<td></td>
<td><code>Qt::Key_MicVolumeDown</code> (0x0100011E)</td>
<td></td>
</tr>
<tr>
<td><code>"MicrophoneVolumeMute"</code></td>
<td>Mutes the microphone input.</td>
<td><code>APPCOMMAND_MICROPHONE_VOLUME_MUTE</code></td>
<td></td>
<td>
<code>GDK_KEY_AudioMicMute</code> (0x1008FFB2)<br /><code
>Qt::Key_MicMute</code
>
(0x01000113)
</td>
<td><code>KEYCODE_MUTE</code> (91)</td>
</tr>
<tr>
<td><code>"MicrophoneVolumeUp"</code></td>
<td>Increases the microphone's input volume.</td>
<td><code>APPCOMMAND_MICROPHONE_VOLUME_UP</code></td>
<td></td>
<td><code>Qt::Key_MicVolumeUp</code> (0x0100011D)</td>
<td></td>
</tr>
</tbody>
</table>
\[1] Legacy Edge and Firefox (48 and earlier) use `"VolumeUp"`, `"VolumeDown"`, and `"VolumeMute"` instead of `"AudioVolumeUp"`, `"AudioVolumeDown"`, and `"AudioVolumeMute"`. In Firefox 49 they were updated to match the latest specification.
## TV control keys
These key values represent buttons or keys present on television devices, or computers or phones which have TV support.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"TV"</code> [1]</td>
<td>Switches into TV viewing mode.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV</code> (170)</td>
</tr>
<tr>
<td><code>"TV3DMode"</code></td>
<td>Toggles 3D TV mode on and off.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_3D_MODE</code> (206)</td>
</tr>
<tr>
<td><code>"TVAntennaCable"</code></td>
<td>Toggles between antenna and cable inputs.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_ANTENNA_CABLE</code> (242)</td>
</tr>
<tr>
<td><code>"TVAudioDescription"</code></td>
<td>Toggles audio description mode on and off.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_AUDIO_DESCRIPTION</code> (252)</td>
</tr>
<tr>
<td><code>"TVAudioDescriptionMixDown"</code></td>
<td>
Decreases the audio description's mixing volume; reduces the volume of
the audio descriptions relative to the program sound.
</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN</code> (254)</td>
</tr>
<tr>
<td><code>"TVAudioDescriptionMixUp"</code></td>
<td>
Increases the audio description's mixing volume; increases the volume of
the audio descriptions relative to the program sound.
</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP</code> (253)</td>
</tr>
<tr>
<td><code>"TVContentsMenu"</code></td>
<td>
Displays or hides the media contents available for playback (this may be
a channel guide showing the currently airing programs, or a list of
media files to play).
</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_CONTENTS_MENU</code> (256)</td>
</tr>
<tr>
<td><code>"TVDataService"</code></td>
<td>Displays or hides the TV's data service menu.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_DATA_SERVICE</code> (230)</td>
</tr>
<tr>
<td><code>"TVInput"</code> [2]</td>
<td>Cycles the input mode on an external TV.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_INPUT</code> (178)</td>
</tr>
<tr>
<td><code>"TVInputComponent1"</code></td>
<td>Switches to the input "Component 1."</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_INPUT_COMPONENT_1</code> (249)</td>
</tr>
<tr>
<td><code>"TVInputComponent2"</code></td>
<td>Switches to the input "Component 2."</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_INPUT_COMPONENT_2</code> (250)</td>
</tr>
<tr>
<td><code>"TVInputComposite1"</code></td>
<td>Switches to the input "Composite 1."</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_INPUT_COMPOSITE_1</code> (247)</td>
</tr>
<tr>
<td><code>"TVInputComposite2"</code></td>
<td>Switches to the input "Composite 2."</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_INPUT_COMPOSITE_2</code> (248)</td>
</tr>
<tr>
<td><code>"TVInputHDMI1"</code></td>
<td>Switches to the input "HDMI 1."</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_INPUT_HDMI_1</code> (243)</td>
</tr>
<tr>
<td><code>"TVInputHDMI2"</code></td>
<td>Switches to the input "HDMI 2."</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_INPUT_HDMI_2</code> (244)</td>
</tr>
<tr>
<td><code>"TVInputHDMI3"</code></td>
<td>Switches to the input "HDMI 3."</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_INPUT_HDMI_3</code> (245)</td>
</tr>
<tr>
<td><code>"TVInputHDMI4"</code></td>
<td>Switches to the input "HDMI 4."</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_INPUT_HDMI_4</code> (246)</td>
</tr>
<tr>
<td><code>"TVInputVGA1"</code></td>
<td>Switches to the input "VGA 1."</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_INPUT_VGA_1</code> (251)</td>
</tr>
<tr>
<td><code>"TVMediaContext"</code></td>
<td>The Media Context menu key.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_MEDIA_CONTEXT_MENU</code> (257)</td>
</tr>
<tr>
<td><code>"TVNetwork"</code></td>
<td>Toggle the TV's network connection on and off.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_NETWORK</code> (241)</td>
</tr>
<tr>
<td><code>"TVNumberEntry"</code></td>
<td>Put the TV into number entry mode.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_NUMBER_ENTRY</code> (234)</td>
</tr>
<tr>
<td><code>"TVPower"</code> [2]</td>
<td>The device's power button.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_POWER</code> (177)</td>
</tr>
<tr>
<td><code>"TVRadioService"</code></td>
<td>Radio button.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_RADIO_SERVICE</code> (232)</td>
</tr>
<tr>
<td><code>"TVSatellite"</code></td>
<td>Satellite button.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_SATELLITE</code> (237)</td>
</tr>
<tr>
<td><code>"TVSatelliteBS"</code></td>
<td>Broadcast Satellite button.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_SATELLITE_BS</code> (238)</td>
</tr>
<tr>
<td><code>"TVSatelliteCS"</code></td>
<td>Communication Satellite button.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_SATELLITE_CS</code> (239)</td>
</tr>
<tr>
<td><code>"TVSatelliteToggle"</code></td>
<td>Toggles among available satellites.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_SATELLITE_SERVICE</code> (240)</td>
</tr>
<tr>
<td><code>"TVTerrestrialAnalog"</code></td>
<td>
Selects analog terrestrial television service (analog cable or antenna
reception).
</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_TERRESTRIAL_ANALOG</code> (235)</td>
</tr>
<tr>
<td><code>"TVTerrestrialDigital"</code></td>
<td>
Selects digital terrestrial television service (digital cable or antenna
reception).
</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_TERRESTRIAL_DIGITAL</code> (236)</td>
</tr>
<tr>
<td><code>"TVTimer"</code></td>
<td>Timer programming button.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_TIMER_PROGRAMMING</code> (258)</td>
</tr>
</tbody>
</table>
\[1] Firefox added proper support for the `"TV"` key in Firefox 37; before that, this key generated the key code `"Live"`.
\[2] These keys were `"Unidentified"` until Firefox 37.
## Media controller keys
Because modern remote controls for media devices often include buttons beyond the basic controls covered elsewhere in this document, key values are defined for a broad array of these additional buttons.
The values below are derived in part from a number of consumer electronics technical specifications:
- [DTV Application Software Environment](https://www.atsc.org/atsc-documents/a100-dtv-application-software-environment-level-1-dase-1/) (part of the [ATSC](https://en.wikipedia.org/wiki/ATSC) specification)
- [Open Cable Application Platform](https://en.wikipedia.org/wiki/OpenCable_Application_Platform)
- [ANSI/CEA-2014-B](https://shop.cta.tech/products/web-based-protocol-and-framework-for-remote-user-interface-on-upnp-networks-and-the-internet): Web-based Protocol and Framework for Remote User Interface on UPnP™ Networks and the Internet
- [Android KeyEvent key code values](https://developer.android.com/reference/android/view/KeyEvent.html)
> **Note:** Remote controls typically include keys whose values are already defined elsewhere, such as under [Multimedia keys](#multimedia_keys) or [Audio control keys](#audio_control_keys). Those keys' values will match what's documented in those tables.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"AVRInput"</code> [3]</td>
<td>
Changes the input mode on an external audio/video receiver (AVR) unit.
</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_AVR_INPUT</code> (182)</td>
</tr>
<tr>
<td><code>"AVRPower"</code> [3]</td>
<td>Toggles the power on an external AVR unit.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_AVR_POWER</code> (181)</td>
</tr>
<tr>
<td><code>"ColorF0Red"</code> [3]</td>
<td>
General-purpose media function key, color-coded red. This has index
<code>0</code> among the colored keys.
</td>
<td><code>VK_COLORED_KEY_0</code></td>
<td></td>
<td></td>
<td><code>KEYCODE_PROG_RED</code> (183)</td>
</tr>
<tr>
<td><code>"ColorF1Green"</code> [3]</td>
<td>
General-purpose media function key, color-coded green. This has index
<code>1</code> among the colored keys.
</td>
<td><code>VK_COLORED_KEY_1</code></td>
<td></td>
<td></td>
<td><code>KEYCODE_PROG_GREEN</code> (184)</td>
</tr>
<tr>
<td><code>"ColorF2Yellow"</code> [3]</td>
<td>
General-purpose media function key, color-coded yellow. This has index
<code>2</code> among the colored keys.
</td>
<td><code>VK_COLORED_KEY_2</code></td>
<td></td>
<td></td>
<td><code>KEYCODE_PROG_YELLOW</code> (185)</td>
</tr>
<tr>
<td><code>"ColorF3Blue"</code> [3]</td>
<td>
General-purpose media function key, color-coded blue. This has index
<code>3</code> among the colored keys.
</td>
<td><code>VK_COLORED_KEY_3</code></td>
<td></td>
<td></td>
<td><code>KEYCODE_PROG_BLUE</code> (186)</td>
</tr>
<tr>
<td><code>"ColorF4Grey"</code></td>
<td>
General-purpose media function key, color-coded grey. This has index
<code>4</code> among the colored keys.
</td>
<td><code>VK_COLORED_KEY_4</code></td>
<td></td>
<td></td>
<td><code>KEYCODE_PROG_GREY</code></td>
</tr>
<tr>
<td><code>"ColorF5Brown"</code></td>
<td>
General-purpose media function key, color-coded brown. This has index
<code>5</code> among the colored keys.
</td>
<td><code>VK_COLORED_KEY_5</code></td>
<td></td>
<td></td>
<td><code>KEYCODE_PROG_BROWN</code></td>
</tr>
<tr>
<td><code>"ClosedCaptionToggle"</code></td>
<td>Toggles closed captioning on and off.</td>
<td><code>VK_CC</code></td>
<td></td>
<td></td>
<td><code>KEYCODE_CAPTIONS</code> (175)</td>
</tr>
<tr>
<td><code>"Dimmer"</code></td>
<td>
Adjusts the brightness of the device by toggling between two brightness
levels <em>or</em> by cycling among multiple brightness levels.
</td>
<td><code>VK_DIMMER</code></td>
<td></td>
<td><code>GDK_KEY_BrightnessAdjust</code> (0x1008FF3B)</td>
<td></td>
</tr>
<tr>
<td><code>"DisplaySwap"</code></td>
<td>Cycles among video sources.</td>
<td><code>VK_DISPLAY_SWAP</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"DVR"</code></td>
<td>Switches the input source to the Digital Video Recorder (DVR).</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_DVR</code> (173)</td>
</tr>
<tr>
<td><code>"Exit"</code></td>
<td>The Exit button, which exits the current application or menu.</td>
<td><code>VK_EXIT</code></td>
<td></td>
<td><code>Qt::Key_Exit</code> (0x0102000a)</td>
<td></td>
</tr>
<tr>
<td><code>"FavoriteClear0"</code></td>
<td>
Clears the program or content stored in the first favorites list slot.
</td>
<td><code>VK_CLEAR_FAVORITE_0</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"FavoriteClear1"</code></td>
<td>
Clears the program or content stored in the second favorites list slot.
</td>
<td><code>VK_CLEAR_FAVORITE_1</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"FavoriteClear2"</code></td>
<td>
Clears the program or content stored in the third favorites list slot.
</td>
<td><code>VK_CLEAR_FAVORITE_2</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"FavoriteClear3"</code></td>
<td>
Clears the program or content stored in the fourth favorites list slot.
</td>
<td><code>VK_CLEAR_FAVORITE_3</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"FavoriteRecall0"</code></td>
<td>
Selects (recalls) the program or content stored in the first favorites
list slot.
</td>
<td><code>VK_RECALL_FAVORITE_0</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"FavoriteRecall1"</code></td>
<td>
Selects (recalls) the program or content stored in the second favorites
list slot.
</td>
<td><code>VK_RECALL_FAVORITE_1</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"FavoriteRecall2"</code></td>
<td>
Selects (recalls) the program or content stored in the third favorites
list slot.
</td>
<td><code>VK_RECALL_FAVORITE_2</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"FavoriteRecall3"</code></td>
<td>
Selects (recalls) the program or content stored in the fourth favorites
list slot.
</td>
<td><code>VK_RECALL_FAVORITE_3</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"FavoriteStore0"</code></td>
<td>
Stores the current program or content into the first favorites list
slot.
</td>
<td><code>VK_STORE_FAVORITE_0</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"FavoriteStore1"</code></td>
<td>
Stores the current program or content into the second favorites list
slot.
</td>
<td><code>VK_STORE_FAVORITE_1</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"FavoriteStore2"</code></td>
<td>
Stores the current program or content into the third favorites list
slot.
</td>
<td><code>VK_STORE_FAVORITE_2</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"FavoriteStore3"</code></td>
<td>
Stores the current program or content into the fourth favorites list
slot.
</td>
<td><code>VK_STORE_FAVORITE_3</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"Guide"</code></td>
<td>Toggles the display of the program or content guide.</td>
<td><code>VK_GUIDE</code></td>
<td></td>
<td><code>Qt::Key_Guide</code> (0x0100011A)</td>
<td><code>KEYCODE_GUIDE</code> (172)</td>
</tr>
<tr>
<td><code>"GuideNextDay"</code></td>
<td>
If the guide is currently displayed, this button tells the guide to
display the next day's content.
</td>
<td><code>VK_NEXT_DAY</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"GuidePreviousDay"</code></td>
<td>
If the guide is currently displayed, this button tells the guide to
display the previous day's content.
</td>
<td><code>VK_PREV_DAY</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"Info"</code></td>
<td>
Toggles the display of information about the currently selected content,
program, or media.
</td>
<td><code>VK_INFO</code></td>
<td></td>
<td><code>Qt::Key_Info</code> (0x0100011B)</td>
<td><code>KEYCODE_INFO</code> (165)</td>
</tr>
<tr>
<td><code>"InstantReplay"</code></td>
<td>
Tells the device to perform an instant replay (typically some form of
jumping back a short amount of time then playing it again, possibly but
not usually in slow motion).
</td>
<td><code>VK_INSTANT_REPLAY</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"Link"</code></td>
<td>
Opens content linked to the current program, if available and possible.
</td>
<td><code>VK_LINK</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"ListProgram"</code></td>
<td>Lists the current program.</td>
<td><code>VK_LIST</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"LiveContent"</code></td>
<td>
Toggles a display listing currently available live content or programs.
</td>
<td><code>VK_LIVE</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"Lock"</code></td>
<td>Locks or unlocks the currently selected content or pgoram.</td>
<td><code>VK_LOCK</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"MediaApps"</code></td>
<td>
Presents a list of media applications, such as photo viewers, audio and
video players, and games. [1]
</td>
<td><code>VK_APPS</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"MediaAudioTrack"</code></td>
<td>The Audio Track key.</td>
<td></td>
<td></td>
<td>
GDK_KEY_AudioCycleTrack (0x1008FF9B)<br /><code
>Qt::Key_AudioCycleTrack</code
>
(0x01000106)
</td>
<td><code>KEYCODE_MEDIA_AUDIO_TRACK</code> (222)</td>
</tr>
<tr>
<td><code>"MediaLast"</code></td>
<td>Jumps back to the last-viewed content, program, or other media.</td>
<td><code>VK_LAST</code></td>
<td></td>
<td><code>Qt::Key_MediaLast</code> (0x0100FFFF)</td>
<td><code>KEYCODE_LAST_CHANNEL</code> (229)</td>
</tr>
<tr>
<td><code>"MediaSkipBackward"</code></td>
<td>Skips backward to the previous content or program.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_MEDIA_SKIP_BACKWARD</code></td>
</tr>
<tr>
<td><code>"MediaSkipForward"</code></td>
<td>Skips forward to the next content or program.</td>
<td><code>VK_SKIP</code></td>
<td></td>
<td></td>
<td><code>KEYCODE_MEDIA_SKIP_FORWARD</code></td>
</tr>
<tr>
<td><code>"MediaStepBackward"</code></td>
<td>Steps backward to the previous content or program.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_MEDIA_STEP_BACKWARD</code></td>
</tr>
<tr>
<td><code>"MediaStepForward"</code></td>
<td>Steps forward to the next content or program.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_MEDIA_SKIP_FORWARD</code></td>
</tr>
<tr>
<td><code>"MediaTopMenu"</code></td>
<td>
Top Menu button. Opens the media's main menu (e.g., for a DVD or Blu-Ray
disc).
</td>
<td></td>
<td></td>
<td><code>Qt::Key_TopMenu</code> (0x0100010A)</td>
<td><code>KEYCODE_MEDIA_TOP_MENU</code></td>
</tr>
<tr>
<td><code>"NavigateIn"</code></td>
<td>Navigates into a submenu or option.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_NAVIGATE_IN</code></td>
</tr>
<tr>
<td><code>"NavigateNext"</code></td>
<td>Navigates to the next item.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_NAVIGATE_NEXT</code></td>
</tr>
<tr>
<td><code>"NavigateOut"</code></td>
<td>Navigates out of the current screen or menu.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_NAVIGATE_OUT</code></td>
</tr>
<tr>
<td><code>"NavigatePrevious"</code></td>
<td>Navigates to the previous item.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_NAVIGATE_PREVIOUS</code></td>
</tr>
<tr>
<td><code>"NextFavoriteChannel"</code></td>
<td>Cycles to the next channel in the favorites list.</td>
<td><code>VK_NEXT_FAVORITE_CHANNEL</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"NextUserProfile"</code></td>
<td>
Cycles to the next saved user profile, if this feature is supported and
multiple profiles exist.
</td>
<td><code>VK_USER</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"OnDemand"</code></td>
<td>
Opens the user interface for selecting on demand content or programs to
watch.
</td>
<td><code>VK_ON_DEMAND</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"Pairing"</code></td>
<td>
Starts the process of pairing the remote with a device to be controlled.
</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_PAIRING</code> (225)</td>
</tr>
<tr>
<td><code>"PinPDown"</code></td>
<td>A button to move the picture-in-picture view downward.</td>
<td><code>VK_PINP_DOWN</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"PinPMove"</code></td>
<td>A button to control moving the picture-in-picture view.</td>
<td><code>VK_PINP_MOVE</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"PinPToggle"</code></td>
<td>Toggles display of the picture-in-picture view on and off.</td>
<td><code>VK_PINP_TOGGLE</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"PinPUp"</code></td>
<td>A button to move the picture-in-picture view upward.</td>
<td><code>VK_PINP_UP</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"PlaySpeedDown"</code></td>
<td>Decreases the media playback rate.</td>
<td><code>VK_PLAY_SPEED_DOWN</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"PlaySpeedReset"</code></td>
<td>Returns the media playback rate to normal.</td>
<td><code>VK_PLAY_SPEED_RESET</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"PlaySpeedUp"</code></td>
<td>Increases the media playback rate.</td>
<td><code>VK_PLAY_SPEED_UP</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"RandomToggle"</code></td>
<td>Toggles random media (also known as "shuffle mode") on and off.</td>
<td><code>VK_RANDOM_TOGGLE</code></td>
<td></td>
<td><code>GDK_KEY_AudioRandomPlay</code> (0x1008FF99)</td>
<td></td>
</tr>
<tr>
<td><code>"RcLowBattery"</code></td>
<td>
A code sent when the remote control's battery is low. This doesn't
actually correspond to a physical key at all.
</td>
<td><code>VK_RC_LOW_BATTERY</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"RecordSpeedNext"</code></td>
<td>Cycles among the available media recording speeds.</td>
<td><code>VK_RECORD_SPEED_NEXT</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"RfBypass"</code></td>
<td>
Toggles radio frequency (RF) input bypass mode on and off. RF bypass
mode passes RF input directly to the RF output without any processing or
filtering.
</td>
<td><code>VK_RF_BYPASS</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"ScanChannelsToggle"</code></td>
<td>
Toggles the channel scan mode on and off. This is a mode which flips
through channels automatically until the user stops the scan.
</td>
<td><code>VK_SCAN_CHANNELS_TOGGLE</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"ScreenModeNext"</code></td>
<td>Cycles through the available screen display modes.</td>
<td><code>VK_SCREEN_MODE_NEXT</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"Settings"</code></td>
<td>Toggles display of the device's settings screen on and off.</td>
<td><code>VK_SETTINGS</code></td>
<td></td>
<td><code>Qt::Key_Settings</code> (0x0100011C)</td>
<td><code>KEYCODE_SETTINGS</code></td>
</tr>
<tr>
<td><code>"SplitScreenToggle"</code></td>
<td>Toggles split screen display mode on and off.</td>
<td><code>VK_SPLIT_SCREEN_TOGGLE</code></td>
<td></td>
<td>
<code>GDK_KEY_SplitScreen (</code>0x1008FF7D)<br /><code
>Qt::Key_SplitScreen</code
>
(0x010000ED)
</td>
<td></td>
</tr>
<tr>
<td><code>"STBInput"</code> [3]</td>
<td>Cycles among input modes on an external set-top box (STB).</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_STB_INPUT</code> (180)</td>
</tr>
<tr>
<td><code>"STBPower"</code> [3]</td>
<td>Toggles on and off an external STB.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_STB_POWER</code> (179)</td>
</tr>
<tr>
<td><code>"Subtitle"</code></td>
<td>Toggles the display of subtitles on and off if they're available.</td>
<td><code>VK_SUBTITLE</code></td>
<td></td>
<td><code>GDK_KEY_Subtitle</code> (0x1008FF9A)</td>
<td><code>KEYCODE_CAPTIONS</code> (175)</td>
</tr>
<tr>
<td><code>"Teletext"</code></td>
<td>
Toggles display of [teletext](https://en.wikipedia.org/wiki/Teletext),
if available.
</td>
<td><code>VK_TELETEXT</code></td>
<td></td>
<td></td>
<td><code>KEYCODE_TV_TELETEXT</code> (233)</td>
</tr>
<tr>
<td><code>"VideoModeNext"</code> [3]</td>
<td>Cycles through the available video modes.</td>
<td><code>VK_VIDEO_MODE_NEXT</code></td>
<td></td>
<td><code>GDK_KEY_Next_VMode</code> (0x1008FE22)</td>
<td></td>
</tr>
<tr>
<td><code>"Wink"</code></td>
<td>
Causes the device to identify itself in some fashion, such as by
flashing a light, briefly changing the brightness of indicator lights,
or emitting a tone.
</td>
<td><code>VK_WINK</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"ZoomToggle"</code> [2]</td>
<td>
Toggles between fullscreen and scaled content display, or otherwise
change the magnification level.
</td>
<td><code>VK_ZOOM</code> (0xFB)</td>
<td></td>
<td><code>Qt::Key_Zoom</code> (0x01020006)</td>
<td><code>KEYCODE_TV_ZOOM_MODE</code> (255)</td>
</tr>
</tbody>
</table>
\[1] Don't confuse the media controller `VK_APPS` key with the Windows `VK_APPS` key, which is also known as `VK_CONTEXT_MENU`. That key is encoded as `"ContextMenu"`.
\[2] Firefox 36 and earlier identifies the zoom toggle button as `"Zoom"`. Firefox 37 corrects this to `"ZoomToggle"`.
\[3] These keys were `"Unidentified"` until Firefox 37.
## Speech recognition keys
These special multimedia keys are used to control speech recognition features.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"SpeechCorrectionList"</code> [1]</td>
<td>
Presents a list of possible corrections for a word which was incorrectly
identified.
</td>
<td><code>APPCOMMAND_CORRECTION_LIST</code></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"SpeechInputToggle"</code> [2]</td>
<td>
Toggles between dictation mode and command/control mode. This lets the
speech engine know whether to interpret spoken words as input text or as
commands.
</td>
<td><code>APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE</code></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
\[1] The `APPCOMMAND_CORRECTION_LIST` command on Windows generates `"Unidentified"` on Firefox.
\[2] The `APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE` command on Windows generates `"Unidentified"` on Firefox.
## Document keys
These keys control documents. In the specification, they're included in other sets of keys (such as the media keys), but they are more sensibly considered to be their own category.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
<tr>
<td><code>"Close"</code> [1]</td>
<td>
Closes the current document or message. Must not exit the application.
</td>
<td><code>APPCOMMAND_CLOSE</code></td>
<td></td>
<td>
<code>GDK_KEY_Close</code> (0x1008FF56)<br /><code>Qt::Key_Close</code>
(0x010000CE)
</td>
<td><code>KEYCODE_MEDIA_CLOSE</code> (128)</td>
</tr>
<tr>
<td><code>"New"</code> [1]</td>
<td>Creates a new document or message.</td>
<td><code>APPCOMMAND_NEW</code></td>
<td></td>
<td>
<code>GDK_KEY_New</code> (0x1008FF68)<br /><code>Qt::Key_New</code>
(0x01000120)
</td>
<td></td>
</tr>
<tr>
<td><code>"Open"</code> [1]</td>
<td>Opens an existing document or message.</td>
<td><code>APPCOMMAND_OPEN</code></td>
<td></td>
<td>
<code>GDK_KEY_Open</code> (0x1008FF6B)<br /><code>Qt::Key_Open</code>
(0x01000121)
</td>
<td></td>
</tr>
<tr>
<td><code>"Print"</code></td>
<td>Prints the current document or message.</td>
<td><code>APPCOMMAND_PRINT</code></td>
<td></td>
<td>
<code>GDK_KEY_Print</code> (0xFF61)<br /><code>Qt::Print</code>
(0x01000009)
</td>
<td></td>
</tr>
<tr>
<td><code>"Save"</code> [1]</td>
<td>Saves the current document or message.</td>
<td><code>APPCOMMAND_SAVE</code></td>
<td></td>
<td>
<code>GDK_KEY_Save</code> (0x1008FF77)<br /><code>Qt::Key_Save</code>
(0x010000EA)
</td>
<td></td>
</tr>
<tr>
<td><code>"SpellCheck"</code> [1]</td>
<td>Starts spell checking the current document.</td>
<td><code>APPCOMMAND_SPELL_CHECK</code></td>
<td></td>
<td>
<code>GDK_KEY_Spell</code> (0x1008FF7C)<br /><code>Qt::Key_Spell</code>
(0x010000EC)
</td>
<td></td>
</tr>
<tr>
<td><code>"MailForward"</code> [1]</td>
<td>Opens the user interface to forward a message.</td>
<td><code>APPCOMMAND_FORWARD_MAIL</code></td>
<td></td>
<td>
<code>GDK_KEY_MailForward</code> (0x1008FF90)<br /><code
>Qt::Key_MailForward</code
>
(0x010000FB)
</td>
<td></td>
</tr>
<tr>
<td><code>"MailReply"</code> [1]</td>
<td>Opens the user interface to reply to a message.</td>
<td><code>APPCOMMAND_REPLY_TO_MAIL</code></td>
<td></td>
<td>
<code>GDK_KEY_Reply</code> (0x1008FF72)<br /><code>Qt::Key_Reply</code>
(0x010000E5)
</td>
<td></td>
</tr>
<tr>
<td><code>"MailSend"</code> [1]</td>
<td>Sends the current message.</td>
<td><code>APPCOMMAND_SEND_MAIL</code></td>
<td></td>
<td>
<code>GDK_KEY_Send</code> (0x1008FF7B)<br /><code>Qt::Key_Send</code>
(0x010000EB)
</td>
<td></td>
</tr>
</thead>
</table>
\[1] Prior to Firefox 37, this key generated the key value `"Unidentified"`.
## Application selector keys
Some keyboards offer special keys for launching or switching to certain common applications. Key values for those are listed here.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"LaunchCalculator"</code> [5]</td>
<td>
The <kbd>Calculator</kbd> key, often labeled with an icon. This is often
used as a generic application launcher key
(<code>APPCOMMAND_LAUNCH_APP2</code>).
</td>
<td><code>APPCOMMAND_LAUNCH_APP2</code></td>
<td></td>
<td>
<code>GDK_KEY_Calculator</code> (0x1008FF1D)<br /><code
>Qt::Key_Calculator</code
>
(0x010000CB)
</td>
<td><code>KEYCODE_CALCULATOR</code> (210)</td>
</tr>
<tr>
<td><code>"LaunchCalendar"</code> [5]</td>
<td>The <kbd>Calendar</kbd> key. Often labeled with an icon.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Calendar</code> (0x1008FF20)<br /><code
>Qt::Key_Calendar</code
>
(0x010000E4)
</td>
<td><code>KEYCODE_CALENDAR</code> (208)</td>
</tr>
<tr>
<td><code>"LaunchContacts"</code></td>
<td>The <kbd>Contacts</kbd> key.</td>
<td></td>
<td></td>
<td></td>
<td><code>KEYCODE_CONTACTS</code> (207)</td>
</tr>
<tr>
<td><code>"LaunchMail"</code></td>
<td>The <kbd>Mail</kbd> key. Often labeled with an icon.</td>
<td>
<code>VK_LAUNCH_MAIL</code> (0xB4)<br /><code
>APPCOMMAND_LAUNCH_MAIL</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_Mail</code> (0x1008FF19)<br /><code
>Qt::Key_LaunchMail</code
>
(0x010000A0)
</td>
<td><code>KEYCODE_ENVELOPE</code> (65)</td>
</tr>
<tr>
<td><code>"LaunchMediaPlayer"</code> [1]</td>
<td>The <kbd>Media Player</kbd> key.</td>
<td>
<code>VK_LAUNCH_MEDIA_SELECT</code> (0xB5)<br /><code
>APPCOMMAND_LAUNCH_MEDIA_SELECT</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_CD</code> (0x1008FF53)<br /><code>GDK_KEY_Video</code>
(0x1008FF87)<br /><code>GDK_KEY_AudioMedia</code>
(0x1008FF32)<br /><code>Qt::Key_LaunchMedia</code> (0x010000A1)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchMusicPlayer"</code> [5]</td>
<td>The <kbd>Music Player</kbd> key. Often labeled with an icon.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Music</code> (0x1008FF92)<br /><code>Qt::Key_Music</code>
(0x010000FD)
</td>
<td><code>KEYCODE_MUSIC</code> (209)</td>
</tr>
<tr>
<td><code>"LaunchMyComputer"</code> [5]</td>
<td>
The <kbd>My Computer</kbd> key on Windows keyboards. This is often used
as a generic application launcher key
(<code>APPCOMMAND_LAUNCH_APP1</code>).
</td>
<td><code>APPCOMMAND_LAUNCH_APP1</code></td>
<td></td>
<td>
<code>GDK_KEY_MyComputer</code> (0x1008FF33)<br /><code
>GDK_KEY_Explorer</code
>
(0x1008FF5D)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchPhone"</code></td>
<td>
The <kbd>Phone</kbd> key. Opens the phone dialer application (if one is
present).
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Phone</code> (0x1008FF6E)<br /><code>Qt::Key_Phone</code>
(0x010000E3)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchScreenSaver"</code> [5]</td>
<td>The <kbd>Screen Saver</kbd> key.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_ScreenSaver</code> (0x1008FF2D)<br /><code
>Qt::Key_ScreenSaver</code
>
(0x010000BA)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchSpreadsheet"</code> [4]</td>
<td>
The <kbd>Spreadsheet</kbd> key. This key may be labeled with an icon.
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Excel</code> (0x1008FF5C)<br /><code>Qt::Key_Excel</code>
(0x010000D4)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchWebBrowser"</code> [4]</td>
<td>
The <kbd>Web Browser</kbd> key. This key is frequently labeled with an
icon.
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_WWW</code> (0x1008FF2E)<br /><code>Qt::Key_WWW</code>
(0x010000BB)
</td>
<td><code>KEYCODE_EXPLORER</code> (64)</td>
</tr>
<tr>
<td><code>"LaunchWebCam"</code> [5]</td>
<td>The <kbd>WebCam</kbd> key. Opens the webcam application.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_WebCam</code> (0x1008FF8F)<br /><code
>Qt::Key_WebCam</code
>
(0x010000FA)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchWordProcessor"</code> [5]</td>
<td>
The <kbd>Word Processor</kbd> key. This may be an icon of a specific
word processor application, or a generic document icon.
</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Word</code> (0x1008FF89)<br /><code>Qt::Key_Word</code>
(0x010000F4)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication1"</code> [2]</td>
<td>The first generic application launcher button.</td>
<td>
<code>VK_LAUNCH_APP1</code> (0xB6)<br /><code
>APPCOMMAND_LAUNCH_APP1</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_Launch0</code> (0x1008FF40)<br /><code
>Qt::Key_Launch0</code
>
(0x010000A2)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication2"</code> [3]</td>
<td>The second generic application launcher button.</td>
<td>
<code>VK_LAUNCH_APP2</code> (0xB7)<br /><code
>APPCOMMAND_LAUNCH_APP2</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_Launch1</code> (0x1008FF41)<br /><code
>Qt::Key_Launch1</code
>
(0x010000A3)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication3"</code></td>
<td>The third generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Launch2</code> (0x1008FF42)<br /><code
>Qt::Key_Launch2</code
>
(0x010000A4)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication4"</code></td>
<td>The fourth generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Launch3</code> (0x1008FF43)<br /><code
>Qt::Key_Launch3</code
>
(0x010000A5)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication5"</code></td>
<td>The fifth generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Launch4</code> (0x1008FF44)<br /><code
>Qt::Key_Launch4</code
>
(0x010000A6)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication6"</code></td>
<td>The sixth generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Launch5</code> (0x1008FF45)<br /><code
>Qt::Key_Launch5</code
>
(0x010000A7)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication7"</code></td>
<td>The seventh generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Launch6</code> (0x1008FF46)<br /><code
>Qt::Key_Launch6</code
>
(0x010000A8)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication8"</code></td>
<td>The eighth generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Launch7</code> (0x1008FF47)<br /><code
>Qt::Key_Launch7</code
>
(0x010000A9)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication9"</code></td>
<td>The ninth generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Launch8</code> (0x1008FF48)<br /><code
>Qt::Key_Launch8</code
>
(0x010000AA)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication10"</code></td>
<td>The 10th generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_Launch9</code> (0x1008FF49)<br /><code
>Qt::Key_Launch9</code
>
(0x010000AB)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication11"</code></td>
<td>The 11th generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_LaunchA</code> (0x1008FF4A)<br /><code
>Qt::Key_LaunchA</code
>
(0x010000AC)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication12"</code></td>
<td>The 12th generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_LaunchB</code> (0x1008FF4B)<br /><code
>Qt::Key_LaunchB</code
>
(0x010000AD)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication13"</code></td>
<td>The 13th generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_LaunchC</code> (0x1008FF4C)<br /><code
>Qt::Key_LaunchC</code
>
(0x010000AE)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication14"</code></td>
<td>The 14th generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_LaunchD</code> (0x1008FF4D)<br /><code
>Qt::Key_LaunchD</code
>
(0x010000AF)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication15"</code></td>
<td>The 15th generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_LaunchE</code> (0x1008FF4E)<br /><code
>Qt::Key_LaunchE</code
>
(0x010000B0)
</td>
<td></td>
</tr>
<tr>
<td><code>"LaunchApplication16"</code></td>
<td>The 16th generic application launcher button.</td>
<td></td>
<td></td>
<td>
<code>GDK_KEY_LaunchF</code> (0x1008FF4F)<br /><code
>Qt::Key_LaunchF</code
>
(0x010000B1)
</td>
<td></td>
</tr>
</tbody>
</table>
\[1] Legacy Edge and Firefox (36 and earlier) use `"SelectMedia"` instead of `"LaunchMediaPlayer"`. Firefox 37 through Firefox 48 use `"MediaSelect"`. Firefox 49 has been updated to match the latest specification, and to return `"LaunchMediaPlayer"`.
\[2] Google Chrome 57 and earlier returned `"LaunchMyComputer"` instead of `"LaunchApplication1"`. See [Chrome Bug 612743](https://crbug.com/612743) for more information.
\[3] Google Chrome 57 and earlier returned `"LaunchCalculator"` instead of `"LaunchApplication2"`. See [Chrome Bug 612743](https://crbug.com/612743) for more information.
\[4] Prior to Firefox 37, Firefox returned the key code `"LaunchApplication1"` instead of "`LaunchWebBrowser"` for the Web browser key.
\[5] Firefox introduced support for this key in Firefox 37. Prior to that, this key was reported as `"Unidentified"`.
## Browser control keys
Some keyboards include special keys for controlling Web browsers. Those keys follow.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"BrowserBack"</code></td>
<td>
Navigates to the previous content or page in the current Web view's
history.
</td>
<td>
<code>VK_BROWSER_BACK</code> (0xA6)<br /><code
>APPCOMMAND_BROWSER_BACKWARD</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_Back</code> (0x1008FF26)<br /><code>Qt::Key_Back</code>
(0x01000061)
</td>
<td><code>KEYCODE_BACK</code> (4)</td>
</tr>
<tr>
<td><code>"BrowserFavorites"</code> [1]</td>
<td>Opens the user's list of bookmarks/favorites.</td>
<td>
<code>VK_BROWSER_FAVORITES</code> (0xAB)<br /><code
>APPCOMMAND_BROWSER_FAVORITES</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_Favorites</code> (0x1008FF30)<br /><code
>GDK_KEY_MySites</code
>
(0x1008FF67)<br /><code>Qt::Favorites</code> (0x01000091)
</td>
<td><code>KEYCODE_BOOKMARK</code> (174)</td>
</tr>
<tr>
<td><code>"BrowserForward"</code></td>
<td>
Navigates to the next content or page in the current Web view's history.
</td>
<td>
<code>VK_BROWSER_FORWARD</code> (0xA7)<br /><code
>APPCOMMAND_BROWSER_FORWARD</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_Forward</code> (0x1008FF27)<br /><code
>Qt::Key_Forward</code
>
(0x01000062)
</td>
<td><code>KEYCODE_FORWARD</code> (125)</td>
</tr>
<tr>
<td><code>"BrowserHome"</code></td>
<td>Navigates to the user's preferred home page.</td>
<td>
<code>VK_BROWSER_HOME</code> (0xAC)<br /><code
>APPCOMMAND_BROWSER_HOME</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_HomePage</code> (0x1008FF18)<br /><code
>Qt::Key_HomePage</code
>
(0x01000090)
</td>
<td><code>KEYCODE_HOME</code> (3)</td>
</tr>
<tr>
<td><code>"BrowserRefresh"</code></td>
<td>Refreshes the current page or content.</td>
<td>
<code>VK_BROWSER_REFRESH</code> (0xA8)<br /><code
>APPCOMMAND_BROWSER_REFRESH</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_Refresh</code> (0x1008FF29)<br /><code
>GDK_KEY_Reload</code
>
(0x1008FF73)
</td>
<td></td>
</tr>
<tr>
<td><code>"BrowserSearch"</code></td>
<td>
Activates the user's preferred search engine or the search interface
within their browser.
</td>
<td>
<code>VK_BROWSER_SEARCH</code> (0xAA)<br /><code
>APPCOMMAND_BROWSER_SEARCH</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_Search</code> (0x1008FF1B)<br /><code
>Qt::Key_Search</code
>
(0x01000092)
</td>
<td><code>KEYCODE_SEARCH</code> (84)</td>
</tr>
<tr>
<td><code>"BrowserStop"</code></td>
<td>Stops loading the currently displayed Web view or content.</td>
<td>
<code>VK_BROWSER_STOP</code> (0xA9)<br /><code
>APPCOMMAND_BROWSER_STOP</code
>
</td>
<td></td>
<td>
<code>GDK_KEY_Stop</code> (0x1008FF28)<br /><code>Qt::Key_Search</code>
(0x01000063)
</td>
<td></td>
</tr>
</tbody>
</table>
\[1] Prior to Firefox 37, this key's value was reported as `"Unidentified"`.
## Numeric keypad keys
These keys are found on the keyboard's numeric keypad. However, not all are present on every keyboard. Although typical numeric keypads have numeric keys from <kbd>0</kbd> to <kbd>9</kbd> (encoded as `"0"` through `"9"`), some multimedia keyboards include additional number keys for higher numbers.
> **Note:** The <kbd>10</kbd> key, if present, generates events with the `key` value of `"0"`.
<table class="no-markdown">
<thead>
<tr>
<th rowspan="2" scope="col"><code>KeyboardEvent.key</code> Value</th>
<th rowspan="2" scope="col">Description</th>
<th colspan="4" scope="col">Virtual Keycode</th>
</tr>
<tr>
<th scope="col">Windows</th>
<th scope="col">Mac</th>
<th scope="col">Linux</th>
<th scope="col">Android</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>"Decimal"</code> [1] {{deprecated_inline}}</td>
<td>
<p>
The decimal point key (typically <kbd>.</kbd> or
<kbd>,</kbd> depending on the region).
</p>
<p>
In newer browsers, this value to be the character generated by the
decimal key (one of those two characters). [1]
</p>
</td>
<td><code>VK_DECIMAL</code> (0x6E)</td>
<td><code>kVK_ANSI_KeypadDecimal</code> (0x41)</td>
<td><code>GDK_KEY_KP_Decimal</code> (0xFFAE)<br /> </td>
<td><code>KEYCODE_NUMPAD_DOT</code> (158)</td>
</tr>
<tr>
<td><code>"Key11"</code></td>
<td>The <kbd>11</kbd> key found on certain media numeric keypads.</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"Key12"</code></td>
<td>The <kbd>12</kbd> key found on certain media numeric keypads.</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><code>"Multiply"</code> [1] {{deprecated_inline}}</td>
<td>The numeric keypad's multiplication key, <kbd>*</kbd>.</td>
<td><code>VK_MULTIPLY</code> (0x6A)</td>
<td><code>kVK_ANSI_KeypadMultiply</code> (0x43)</td>
<td>
<code>GDK_KEY_KP_Multiply</code> (0xFFAA)<br /><code
>Qt::Key_Multiply</code
>
(0x0D7)
</td>
<td><code>KEYCODE_NUMPAD_MULTIPLY</code> (155)</td>
</tr>
<tr>
<td><code>"Add"</code> [1] {{deprecated_inline}}</td>
<td>The numeric keypad's addition key, <kbd>+</kbd>.</td>
<td><code>VK_ADD</code> (0x6B)</td>
<td><code>kVK_ANSI_KeypadPlus</code> (0x45)</td>
<td><code>GDK_KEY_KP_Add</code> (0xFFAB)</td>
<td><code>KEYCODE_NUMPAD_ADD</code> (157)</td>
</tr>
<tr>
<td><code>"Clear"</code></td>
<td>The numeric keypad's <kbd>Clear</kbd> key.</td>
<td></td>
<td><code>kVK_ANSI_KeypadClear</code> (0x47)</td>
<td>
<code>GDK_KEY_Clear</code> (0xFF0B)<br /><code>Qt::Key_Clear</code>
(0x0100000B)
</td>
<td><code>KEYCODE_CLEAR</code> (28)</td>
</tr>
<tr>
<td><code>"Divide"</code> [1] {{deprecated_inline}}</td>
<td>The numeric keypad's division key, <kbd>/</kbd>.</td>
<td><code>VK_DIVIDE</code> (0x6F)</td>
<td><code>kVK_ANSI_KeypadDivide</code> (0x4B)</td>
<td>
<code>GDK_KEY_KP_Divide</code> (0xFFAF)<br /><code>Qt::Key_Slash</code>
(0x2F)
</td>
<td><code>KEYCODE_NUMPAD_DIVIDE</code> (154)</td>
</tr>
<tr>
<td><code>"Subtract"</code> [1] {{deprecated_inline}}</td>
<td>The numeric keypad's subtraction key, <kbd>-</kbd>.</td>
<td><code>VK_SUBTRACT</code> (0x6D)</td>
<td><code>kVK_ANSI_KeypadMinus</code> (0x4E)</td>
<td><code>GDK_KEY_KP_Subtract</code> (0xFFAD)</td>
<td><code>KEYCODE_NUMPAD_SUBTRACT</code> (156)</td>
</tr>
<tr>
<td><code>"Separator"</code> [1]</td>
<td>
<p>The numeric keypad's places separator character.</p>
<p>
(In the United States this is a comma, but elsewhere it is frequently
a period.)
</p>
</td>
<td><code>VK_SEPARATOR</code> (0x6C)</td>
<td><code>kVK_JIS_KeypadComma</code> (0x5F)</td>
<td><code>GDK_KEY_KP_Separator</code> (0xFFAC)<br /> </td>
<td><code>KEYCODE_NUMPAD_COMMA</code> (159)</td>
</tr>
<tr>
<td><code>"0"</code> through <code>"9"</code></td>
<td>The actual digit keys on the numeric keypad.</td>
<td><code>VK_NUMPAD0</code> (0x60) - <code>VK_NUMPAD9</code> (0x69)</td>
<td><code>kVK_Keypad0</code> (0x52) - <code>kVK_Keypad9</code> (0x5C)</td>
<td>
<code>GDK_KEY_KP_0</code> (0xFFB0) - <code>GDK_KEY_KP_9</code> (0xFFB9)
</td>
<td>
<code>KEYCODE_NUMPAD_0</code> (144) -
<code>KEYCODE_NUMPAD_9</code> (153)
</td>
</tr>
</tbody>
</table>
\[1] While older browsers used words like `"Add"`, `"Decimal"`, `"Multiply"`, and so forth modern browsers identify these using the actual character (`"+"`, `"."`, `"*"`, and so forth).
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/trackevent/index.md | ---
title: TrackEvent
slug: Web/API/TrackEvent
page-type: web-api-interface
browser-compat: api.TrackEvent
---
{{APIRef("HTML DOM")}}
The **`TrackEvent`** interface, which is part of the HTML DOM specification, is used for events which represent changes to a set of available tracks on an HTML media element; these events are `addtrack` and `removetrack`.
It's important not to confuse `TrackEvent` with the {{domxref("RTCTrackEvent")}} interface, which is used for tracks which are part of an {{domxref("RTCPeerConnection")}}.
Events based on `TrackEvent` are always sent to one of the media track list types:
- Events involving video tracks are always sent to the {{domxref("VideoTrackList")}} found in {{domxref("HTMLMediaElement.videoTracks")}}
- Events involving audio tracks are always sent to the {{domxref("AudioTrackList")}} specified in {{domxref("HTMLMediaElement.audioTracks")}}
- Events affecting text tracks are sent to the {{domxref("TextTrackList")}} object indicated by {{domxref("HTMLMediaElement.textTracks")}}.
{{InheritanceDiagram}}
## Constructor
- {{domxref("TrackEvent.TrackEvent", "TrackEvent()")}}
- : Creates and initializes a new `TrackEvent` object with the event type specified, as well as optional additional properties.
## Instance properties
_`TrackEvent` is based on {{domxref("Event")}}, so properties of `Event` are also available on `TrackEvent` objects._
- {{domxref("TrackEvent.track", "track")}} {{ReadOnlyInline}}
- : The DOM track object the event is in reference to. If not `null`, this is always an object of one of the media track types: {{domxref("AudioTrack")}}, {{domxref("VideoTrack")}}, or {{domxref("TextTrack")}}).
## Instance methods
_`TrackEvent` has no methods of its own; however, it is based on {{domxref("Event")}}, so it provides the methods available on `Event` objects._
## Example
This example sets up a function, `handleTrackEvent()`, which is called for any `addtrack` or `removetrack` event on the first {{HTMLElement("video")}} element found in the document.
```js
const videoElem = document.querySelector("video");
videoElem.videoTracks.addEventListener("addtrack", handleTrackEvent, false);
videoElem.videoTracks.addEventListener("removetrack", handleTrackEvent, false);
videoElem.audioTracks.addEventListener("addtrack", handleTrackEvent, false);
videoElem.audioTracks.addEventListener("removetrack", handleTrackEvent, false);
videoElem.textTracks.addEventListener("addtrack", handleTrackEvent, false);
videoElem.textTracks.addEventListener("removetrack", handleTrackEvent, false);
function handleTrackEvent(event) {
let trackKind;
if (event.target instanceof VideoTrackList) {
trackKind = "video";
} else if (event.target instanceof AudioTrackList) {
trackKind = "audio";
} else if (event.target instanceof TextTrackList) {
trackKind = "text";
} else {
trackKind = "unknown";
}
switch (event.type) {
case "addtrack":
console.log(`Added a ${trackKind} track`);
break;
case "removetrack":
console.log(`Removed a ${trackKind} track`);
break;
}
}
```
The event handler uses the JavaScript [`instanceof`](/en-US/docs/Web/JavaScript/Reference/Operators/instanceof) operator to determine which type of track the event occurred on, then outputs to console a message indicating what kind of track it is and whether it's being added to or removed from the element.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/trackevent | data/mdn-content/files/en-us/web/api/trackevent/trackevent/index.md | ---
title: "TrackEvent: TrackEvent() constructor"
short-title: TrackEvent()
slug: Web/API/TrackEvent/TrackEvent
page-type: web-api-constructor
browser-compat: api.TrackEvent.TrackEvent
---
{{APIRef("HTML DOM")}}
The **`TrackEvent()`** constructor
creates and returns a new {{domxref("TrackEvent")}} object describing an event which
occurred on a list of tracks ({{domxref("AudioTrackList")}},
{{domxref("VideoTrackList")}}, or {{domxref("TextTrackList")}}).
## Syntax
```js-nolint
new TrackEvent(type)
new TrackEvent(type, options)
```
### Parameters
- `type`
- : A string with the name of the event.
It is case-sensitive and browsers set it to `addtrack` or `removetrack`.
- `options` {{optional_inline}}
- : An object that, _in addition of the properties defined in {{domxref("Event/Event", "Event()")}}_, can have the following properties:
- `track` {{optional_inline}}
- : The track to which the event refers; this is `null` by default, but
should be set to a {{domxref("VideoTrack")}}, {{domxref("AudioTrack")}}, or
{{domxref("TextTrack")}} as appropriate given the type of track.
### Return value
A new {{domxref("TrackEvent")}} object, initialized as described by the
inputs to the constructor.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/trackevent | data/mdn-content/files/en-us/web/api/trackevent/track/index.md | ---
title: "TrackEvent: track property"
short-title: track
slug: Web/API/TrackEvent/track
page-type: web-api-instance-property
browser-compat: api.TrackEvent.track
---
{{APIRef("HTML DOM")}}
The read-only **`track`** property of
the {{domxref("TrackEvent")}} interface specifies the media track object to which the
event applies.
The media track will be an {{domxref("AudioTrack")}},
{{domxref("VideoTrack")}}, or {{domxref("TextTrack")}} object.
## Value
An object which is one of the types {{domxref("AudioTrack")}},
{{domxref("VideoTrack")}}, or {{domxref("TextTrack")}}, depending on the type of media
represented by the track. This identifies the track to which the event applies.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/web_share_api/index.md | ---
title: Web Share API
slug: Web/API/Web_Share_API
page-type: web-api-overview
browser-compat:
- api.Navigator.share
- api.Navigator.canShare
---
{{DefaultAPISidebar("Web Share API")}}
The **Web Share API** provides a mechanism for sharing text, links, files, and other content to an arbitrary _share target_ selected by the user.
{{securecontext_header}}
> **Note:** This API is _not available_ in [Web Workers](/en-US/docs/Web/API/Web_Workers_API) (not exposed via {{domxref("WorkerNavigator")}}).
> **Note:** This API should not be confused with the [Web Share Target API](/en-US/docs/Web/Manifest/share_target), which allows a website to specify itself as a share target.
## Concepts and usage
The **Web Share API** allows a site to share text, links, files, and other content to user-selected share targets, utilizing the sharing mechanisms of the underlying operating system.
These share targets typically include the system clipboard, email, contacts or messaging applications, and Bluetooth or Wi-Fi channels.
The API has just two methods.
The {{domxref("navigator.canShare()")}} method may be used to first validate whether some data is "shareable", prior to passing it to {{domxref("navigator.share()")}} for sending.
The {{domxref("navigator.share()")}} method invokes the native sharing mechanism of the underlying operating system and passes the specified data.
It requires {{Glossary("transient activation")}}, and hence must be triggered off a UI event like a button click.
Further, the method must specify valid data that is supported for sharing by the native implementation.
The Web Share API is gated by the [web-share](/en-US/docs/Web/HTTP/Headers/Permissions-Policy/web-share) Permissions Policy.
If the policy is supported but has not been granted, both methods will indicate that the data is not shareable.
## Interfaces
- {{domxref("navigator.canShare()")}}
- : Returns a boolean indicating whether the specified data is shareable.
- {{domxref("navigator.share()")}}
- : Returns a {{jsxref("Promise")}} that resolves if the passed data was successfully sent to a share target.
This method must be called on a button click or other user activation (requires {{Glossary("transient activation")}}).
## Example
The code below shows how you can share a link using {{domxref("navigator.share()")}}, triggered off a button click.
```js
const shareData = {
title: "MDN",
text: "Learn web development on MDN!",
url: "https://developer.mozilla.org",
};
const btn = document.querySelector("button");
const resultPara = document.querySelector(".result");
// Share must be triggered by "user activation"
btn.addEventListener("click", async () => {
try {
await navigator.share(shareData);
resultPara.textContent = "MDN shared successfully";
} catch (err) {
resultPara.textContent = `Error: ${err}`;
}
});
```
The above example is taken from our [Web share test](https://mdn.github.io/dom-examples/web-share/) ([see the source code](https://github.com/mdn/dom-examples/blob/main/web-share/index.html)). You can also see this as a live example in {{domxref("navigator.share()")}}.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Web Share Target API](/en-US/docs/Web/Manifest/share_target)
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/cookie_store_api/index.md | ---
title: Cookie Store API
slug: Web/API/Cookie_Store_API
page-type: web-api-overview
browser-compat:
- api.CookieStore
- api.CookieStoreManager
spec-urls: https://wicg.github.io/cookie-store/
---
{{securecontext_header}}{{DefaultAPISidebar("Cookie Store API")}}
The **Cookie Store API** is an asynchronous API for managing cookies, available in windows and also [service workers](/en-US/docs/Web/API/Service_Worker_API).
{{AvailableInWorkers}}
## Concepts and Usage
The existing method of getting and setting cookies involves working with {{domxref("document.cookie")}} as a string of key/value pairs. In addition to this being cumbersome and error prone, it also has a host of issues in the context of modern web development.
The `document.cookie` interface is {{Glossary("synchronous")}}, single-threaded, and blocking. When writing a cookie you must wait for the browser to update the string of all cookies. In addition, the reliance on {{domxref("document")}} means that cookies cannot be accessed by service workers which cannot access the `document` object.
The _Cookie Store API_ provides an updated method of managing cookies. It is {{Glossary("asynchronous")}} and promise-based, therefore does not block the event loop. It does not rely on {{domxref("document")}} and so is available to service workers. The methods for getting and setting cookies also provide more feedback by way of error messages. This means that web developers do not have to set then immediately read back a cookie to check that setting was successful.
## Interfaces
- {{domxref("CookieStore")}} {{Experimental_Inline}}
- : The `CookieStore` interface enables getting and setting cookies.
- {{domxref("CookieStoreManager")}} {{Experimental_Inline}}
- : The `CookieStoreManager` interface provides a service worker registration to enable service workers to subscribe to cookie change events.
- {{domxref("CookieChangeEvent")}} {{Experimental_Inline}}
- : A `CookieChangeEvent` named `change` is dispatched against `CookieStore` objects in {{domxref("Window")}} contexts when any script-visible cookies changes occur.
- {{domxref("ExtendableCookieChangeEvent")}}
- : An `ExtendableCookieChangeEvent` named `cookiechange` is dispatched in {{domxref("ServiceWorkerGlobalScope")}} contexts when any script-visible cookie changes occur that match the service worker's cookie change subscription list.
### Extensions to other interfaces
- {{domxref("ServiceWorkerGlobalScope.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Returns a reference to the {{domxref("CookieStore")}} object associated with the service worker.
- {{domxref("ServiceWorkerRegistration.cookies")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Returns a reference to the {{domxref("CookieStoreManager")}} interface, which enables a web app to subscribe to and unsubscribe from cookie change events.
- {{domxref("Window.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}}
- : Returns a reference to the {{domxref("CookieStore")}} object for the current document context.
- {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} event {{Experimental_Inline}}
- : Fired when any cookie changes have occurred which match the service worker's cookie change subscription list.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Service Worker API](/en-US/docs/Web/API/Service_Worker_API)
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/cssnumericarray/index.md | ---
title: CSSNumericArray
slug: Web/API/CSSNumericArray
page-type: web-api-interface
browser-compat: api.CSSNumericArray
---
{{APIRef("CSS Typed Object Model API")}}
The **`CSSNumericArray`** interface of the {{domxref('CSS_Object_Model#css_typed_object_model','','',' ')}} contains a list of {{domxref("CSSNumericValue")}} objects.
## Instance properties
- {{domxref("CSSNumericArray.length")}} {{ReadOnlyInline}}
- : Returns how many {{domxref("CSSNumericValue")}} objects are contained within the `CSSNumericArray`.
## Examples
To do.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/cssnumericarray | data/mdn-content/files/en-us/web/api/cssnumericarray/length/index.md | ---
title: "CSSNumericArray: length property"
short-title: length
slug: Web/API/CSSNumericArray/length
page-type: web-api-instance-property
browser-compat: api.CSSNumericArray.length
---
{{APIRef("CSS Typed OM")}}
The read-only **`length`** property of the
{{domxref("CSSNumericArray")}} interface returns the number of
{{domxref("CSSNumericValue")}} objects in the list.
## Value
An integer representing the number of {{domxref("CSSNumericValue")}} objects in the
list.
## Examples
To Do
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/convolvernode/index.md | ---
title: ConvolverNode
slug: Web/API/ConvolverNode
page-type: web-api-interface
browser-compat: api.ConvolverNode
---
{{APIRef("Web Audio API")}}
The `ConvolverNode` interface is an {{domxref("AudioNode")}} that performs a Linear Convolution on a given {{domxref("AudioBuffer")}}, often used to achieve a reverb effect. A `ConvolverNode` always has exactly one input and one output.
> **Note:** For more information on the theory behind Linear Convolution, see the [Convolution article on Wikipedia](https://en.wikipedia.org/wiki/Convolution).
{{InheritanceDiagram}}
<table class="properties">
<tbody>
<tr>
<th scope="row">Number of inputs</th>
<td><code>1</code></td>
</tr>
<tr>
<th scope="row">Number of outputs</th>
<td><code>1</code></td>
</tr>
<tr>
<th scope="row">Channel count mode</th>
<td><code>"clamped-max"</code></td>
</tr>
<tr>
<th scope="row">Channel count</th>
<td><code>1</code>, <code>2</code>, or <code>4</code></td>
</tr>
<tr>
<th scope="row">Channel interpretation</th>
<td><code>"speakers"</code></td>
</tr>
</tbody>
</table>
## Constructor
- {{domxref("ConvolverNode.ConvolverNode()", "ConvolverNode()")}}
- : Creates a new `ConvolverNode` object instance.
## Instance properties
_Inherits properties from its parent, {{domxref("AudioNode")}}_.
- {{domxref("ConvolverNode.buffer")}}
- : A mono, stereo, or 4-channel _{{domxref("AudioBuffer")}}_ containing the (possibly multichannel) impulse response used by the `ConvolverNode` to create the reverb effect.
- {{domxref("ConvolverNode.normalize")}}
- : A boolean that controls whether the impulse response from the buffer will be scaled by an equal-power normalization when the `buffer` attribute is set, or not.
## Instance methods
_No specific method; inherits methods from its parent, {{domxref("AudioNode")}}_.
## ConvolverNode Example
The following example shows basic usage of an AudioContext to create a convolver node.
> **Note:** You will need to find an impulse response to complete the example below. See this [Codepen](https://codepen.io/DonKarlssonSan/pen/doVKRE) for an applied example.
```js
let audioCtx = new window.AudioContext();
async function createReverb() {
let convolver = audioCtx.createConvolver();
// load impulse response from file
let response = await fetch("path/to/impulse-response.wav");
let arraybuffer = await response.arrayBuffer();
convolver.buffer = await audioCtx.decodeAudioData(arraybuffer);
return convolver;
}
// …
let reverb = await createReverb();
// someOtherAudioNode -> reverb -> destination
someOtherAudioNode.connect(reverb);
reverb.connect(audioCtx.destination);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Using the Web Audio API](/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API)
| 0 |
data/mdn-content/files/en-us/web/api/convolvernode | data/mdn-content/files/en-us/web/api/convolvernode/buffer/index.md | ---
title: "ConvolverNode: buffer property"
short-title: buffer
slug: Web/API/ConvolverNode/buffer
page-type: web-api-instance-property
browser-compat: api.ConvolverNode.buffer
---
{{ APIRef("Web Audio API") }}
The **`buffer`** property of the {{ domxref("ConvolverNode") }} interface represents a mono, stereo, or 4-channel {{domxref("AudioBuffer")}} containing the (possibly multichannel) impulse response used by the `ConvolverNode` to create the reverb effect.
This is normally a simple recording of as-close-to-an-impulse as can be found in the space you want to model. For example, if you want to model the reverb in your bathroom, you might set up a microphone near the door to record the sound of a balloon pop or synthesized impulse from the sink. That audio recording could then be used as the buffer.
This audio buffer must have the same sample-rate as the `AudioContext` or an exception will be thrown. At the time when this attribute is set, the buffer and the state of the attribute will be used to configure the `ConvolverNode` with this impulse response having the given normalization. The initial value of this attribute is `null`.
## Value
An {{domxref("AudioBuffer")}}.
## Examples
### Assigning an audio buffer
The following example creates a convolver node and assigns it an {{domxref("AudioBuffer")}}.
For more complete applied examples/information, check out our [Voice-change-O-matic](https://mdn.github.io/webaudio-examples/voice-change-o-matic/) demo (see [app.js](https://github.com/mdn/webaudio-examples/blob/main/voice-change-o-matic/scripts/app.js) for the code that is excerpted below).
```js
const audioCtx = new AudioContext();
// ...
const convolver = audioCtx.createConvolver();
// ...
// Grab audio track via fetch() for convolver node
try {
const response = await fetch(
"https://mdn.github.io/voice-change-o-matic/audio/concert-crowd.ogg",
);
const arrayBuffer = await response.arrayBuffer();
const decodedAudio = await audioCtx.decodeAudioData(arrayBuffer);
convolver.buffer = decodedAudio;
} catch (error) {
console.error(
`Unable to fetch the audio file: ${name} Error: ${err.message}`,
);
}
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Using the Web Audio API](/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API)
| 0 |
data/mdn-content/files/en-us/web/api/convolvernode | data/mdn-content/files/en-us/web/api/convolvernode/convolvernode/index.md | ---
title: "ConvolverNode: ConvolverNode() constructor"
short-title: ConvolverNode()
slug: Web/API/ConvolverNode/ConvolverNode
page-type: web-api-constructor
browser-compat: api.ConvolverNode.ConvolverNode
---
{{APIRef("Web Audio API")}}
The **`ConvolverNode()`** constructor of the [Web Audio API](/en-US/docs/Web/API/Web_Audio_API) creates a new
{{domxref("ConvolverNode")}} object instance.
## Syntax
```js-nolint
new ConvolverNode(context, options)
```
### Parameters
- `context`
- : A reference to an {{domxref("AudioContext")}}.
- `options` {{optional_inline}}
- : Options are as follows:
- `buffer`
- : A mono, stereo, or
4-channel {{domxref("AudioBuffer")}} containing the
(possibly multichannel) impulse response used by the `ConvolverNode`
to create the reverb effect.
- `disableNormalization`
- : A boolean value controlling
whether the impulse response from the buffer will be scaled by an equal-power
normalization, or not. The default is '`false`'.
- `channelCount`
- : Represents an integer used to determine how many channels are used
when [up-mixing and down-mixing](/en-US/docs/Web/API/Web_Audio_API/Basic_concepts_behind_Web_Audio_API#up-mixing_and_down-mixing) connections to any inputs to the node.
(See {{domxref("AudioNode.channelCount")}} for more information.)
Its usage and precise definition depend on the value of `channelCountMode`.
- `channelCountMode`
- : Represents an enumerated value describing the way channels must be matched between the node's inputs and outputs.
(See {{domxref("AudioNode.channelCountMode")}} for more information including default values.)
- `channelInterpretation`
- : Represents an enumerated value describing the meaning of the channels.
This interpretation will define how audio [up-mixing and down-mixing](/en-US/docs/Web/API/Web_Audio_API/Basic_concepts_behind_Web_Audio_API#up-mixing_and_down-mixing) will happen.
The possible values are `"speakers"` or `"discrete"`.
(See {{domxref("AudioNode.channelCountMode")}} for more information including default values.)
### Return value
A new {{domxref("ConvolverNode")}} object instance.
### Exceptions
- `NotSupportedError` {{domxref("DOMException")}}
- : Thrown if the referenced {{domxref("AudioBuffer")}} does not have the
correct number of channels, or it has a different sample rate to the
associated {{domxref("AudioContext")}}.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/convolvernode | data/mdn-content/files/en-us/web/api/convolvernode/normalize/index.md | ---
title: "ConvolverNode: normalize property"
short-title: normalize
slug: Web/API/ConvolverNode/normalize
page-type: web-api-instance-property
browser-compat: api.ConvolverNode.normalize
---
{{ APIRef("Web Audio API") }}
The `normalize` property of the {{ domxref("ConvolverNode") }} interface
is a boolean that controls whether the impulse response from the buffer will be
scaled by an equal-power normalization when the `buffer` attribute is set,
or not.
Its default value is `true` in order to achieve a more uniform output
level from the convolver, when loaded with diverse impulse responses. If normalize is
set to `false`, then the convolution will be rendered with no
pre-processing/scaling of the impulse response. Changes to this value do not take
effect until the next time the `buffer` attribute is set.
## Value
A boolean.
## Examples
### Switching normalization off
The following example creates a convolver node and assigns it an {{domxref("AudioBuffer")}}. Before assigning the audio buffer, it sets `normalize` to `false`.
```js
const audioCtx = new AudioContext();
// ...
const convolver = audioCtx.createConvolver();
// ...
// Grab audio track via fetch() for convolver node
try {
const response = await fetch(
"https://mdn.github.io/voice-change-o-matic/audio/concert-crowd.ogg",
);
const arrayBuffer = await response.arrayBuffer();
const decodedAudio = await audioCtx.decodeAudioData(arrayBuffer);
convolver.normalize = false; // must be set before the buffer, to take effect
convolver.buffer = decodedAudio;
} catch (error) {
console.error(
`Unable to fetch the audio file: ${name} Error: ${err.message}`,
);
}
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Using the Web Audio API](/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API)
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/offlineaudiocompletionevent/index.md | ---
title: OfflineAudioCompletionEvent
slug: Web/API/OfflineAudioCompletionEvent
page-type: web-api-interface
browser-compat: api.OfflineAudioCompletionEvent
---
{{APIRef("Web Audio API")}}
The [Web Audio API](/en-US/docs/Web/API/Web_Audio_API) `OfflineAudioCompletionEvent` interface represents events that occur when the processing of an {{domxref("OfflineAudioContext")}} is terminated. The {{domxref("OfflineAudioContext/complete_event", "complete")}} event uses this interface.
> **Note:** This interface is marked as deprecated; it is still supported for legacy reasons, but it will soon be superseded when the promise version of {{domxref("OfflineAudioContext.startRendering")}} is supported in browsers, which will no longer need it.
{{InheritanceDiagram}}
## Constructor
- {{domxref("OfflineAudioCompletionEvent.OfflineAudioCompletionEvent", "OfflineAudioCompletionEvent()")}}
- : Creates a new `OfflineAudioCompletionEvent` object instance.
## Instance properties
_Also inherits properties from its parent, {{domxref("Event")}}_.
- {{domxref("OfflineAudioCompletionEvent.renderedBuffer")}} {{ReadOnlyInline}}
- : An {{domxref("AudioBuffer")}} containing the result of processing an {{domxref("OfflineAudioContext")}}.
## Instance methods
_Inherits methods from its parent, {{domxref("Event")}}_.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Using the Web Audio API](/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API)
| 0 |
data/mdn-content/files/en-us/web/api/offlineaudiocompletionevent | data/mdn-content/files/en-us/web/api/offlineaudiocompletionevent/offlineaudiocompletionevent/index.md | ---
title: "OfflineAudioCompletionEvent: OfflineAudioCompletionEvent() constructor"
short-title: OfflineAudioCompletionEvent()
slug: Web/API/OfflineAudioCompletionEvent/OfflineAudioCompletionEvent
page-type: web-api-constructor
browser-compat: api.OfflineAudioCompletionEvent.OfflineAudioCompletionEvent
---
{{APIRef("Web Audio API")}}
The **`OfflineAudioCompletionEvent()`** constructor of the [Web Audio API](/en-US/docs/Web/API/Web_Audio_API) creates a new
{{domxref("OfflineAudioCompletionEvent")}} object.
> **Note:** You wouldn't generally use the constructor manually.
> `OfflineAudioCompletionEvent` events are dispatched to
> {{domxref("OfflineAudioContext")}} instances for legacy reasons.
## Syntax
```js-nolint
new OfflineAudioCompletionEvent(type, options)
```
### Parameters
- `type`
- : A string with the name of the event.
It is case-sensitive and browsers set it to `complete`.
- `options`
- : An object that, _in addition of the properties defined in {{domxref("Event/Event", "Event()")}}_, can have the following properties:
- `renderedBuffer`
- : The rendered {{domxref("AudioBuffer")}} containing the audio data.
### Return value
A new {{domxref("OfflineAudioCompletionEvent")}} object.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/offlineaudiocompletionevent | data/mdn-content/files/en-us/web/api/offlineaudiocompletionevent/renderedbuffer/index.md | ---
title: "OfflineAudioCompletionEvent: renderedBuffer property"
short-title: renderedBuffer
slug: Web/API/OfflineAudioCompletionEvent/renderedBuffer
page-type: web-api-instance-property
browser-compat: api.OfflineAudioCompletionEvent.renderedBuffer
---
{{APIRef("Web Audio API")}}
The **`renderedBuffer`** read-only property of the
{{domxref("OfflineAudioCompletionEvent")}} interface is an {{domxref("AudioBuffer")}}
containing the result of processing an {{domxref("OfflineAudioContext")}}.
## Value
An {{domxref("AudioBuffer")}}.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/crypto_property/index.md | ---
title: crypto global property
short-title: crypto
slug: Web/API/crypto_property
page-type: web-api-global-property
browser-compat: api.crypto
---
{{APIRef("Web Crypto API")}}{{AvailableInWorkers}}
The global read-only **`crypto`** property returns the {{domxref("Crypto")}} object associated to the global object. This object allows web pages access to certain cryptographic related services.
Although the property itself is read-only, all of its methods (and the methods of its
child object, {{domxref("SubtleCrypto")}}) are not read-only, and therefore vulnerable
to attack by {{glossary("polyfill")}}.
Although `crypto` is available on all windows, the returned `Crypto` object only has one usable feature in insecure contexts: the {{domxref("Crypto.getRandomValues", "getRandomValues()")}} method. In general, you should use this API only in secure contexts.
## Value
An instance of the {{domxref("Crypto")}} interface, providing access to general-purpose cryptography and a strong random-number generator.
## Examples
This example uses the `crypto` property to access the {{domxref("Crypto.getRandomValues", "getRandomValues()")}} method.
### JavaScript
```js
globalThis.genRandomNumbers = () => {
const array = new Uint32Array(10);
crypto.getRandomValues(array);
const randText = document.getElementById("myRandText");
randText.textContent = `The random numbers are: ${array.join(" ")}`;
};
```
### HTML
```html
<p id="myRandText">The random numbers are:</p>
<button type="button" onClick="genRandomNumbers()">
Generate 10 random numbers
</button>
```
### Result
{{EmbedLiveSample('Examples')}}
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- The {{domxref("Window")}} global object
- The {{domxref("Crypto")}} interface
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/cspviolationreportbody/index.md | ---
title: CSPViolationReportBody
slug: Web/API/CSPViolationReportBody
page-type: web-api-interface
browser-compat: api.CSPViolationReportBody
---
{{APIRef("Reporting API")}}{{SecureContext_Header}}
The `CSPViolationReportBody` interface contains the report data for a Content Security Policy (CSP) violation. CSP violations are thrown when the webpage attempts to load a resource that violates the CSP set by the {{HTTPHeader("Content-Security-Policy")}} HTTP header.
> **Note:** this interface is similar, but not identical to, the [JSON objects](/en-US/docs/Web/HTTP/CSP#violation_report_syntax) sent back to the [`report-uri`](/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/report-uri) or [`report-to`](/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/report-to) policy directive of the {{HTTPHeader("Content-Security-Policy")}} header.
{{InheritanceDiagram}}
## Instance properties
_Also inherits properties from its parent interface, {{DOMxRef("ReportBody")}}._
- {{domxref("CSPViolationReportBody.blockedURL")}} {{ReadOnlyInline}}
- : A string representing the URL of the resource that was blocked because it violates the CSP.
- {{domxref("CSPViolationReportBody.columnNumber")}} {{ReadOnlyInline}}
- : The column number in the script at which the violation occurred.
- {{domxref("CSPViolationReportBody.disposition")}} {{ReadOnlyInline}}
- : Indicates how the violated policy is configured to be treated by the user agent. This will be `"enforce"` or `"report"`.
- {{domxref("CSPViolationReportBody.documentURL")}} {{ReadOnlyInline}}
- : A string representing the URL of the document or worker in which the violation was found.
- {{domxref("CSPViolationReportBody.effectiveDirective")}} {{ReadOnlyInline}}
- : A string representing the directive whose enforcement uncovered the violation.
- {{domxref("CSPViolationReportBody.lineNumber")}} {{ReadOnlyInline}}
- : The line number in the script at which the violation occurred.
- {{domxref("CSPViolationReportBody.originalPolicy")}} {{ReadOnlyInline}}
- : A string containing the policy whose enforcement uncovered the violation.
- {{domxref("CSPViolationReportBody.referrer")}} {{ReadOnlyInline}}
- : A string representing the URL for the referrer of the resources whose policy was violated, or `null`.
- {{domxref("CSPViolationReportBody.sample")}} {{ReadOnlyInline}}
- : A string representing a sample of the resource that caused the violation, usually the first 40 characters. This will only be populated if the resource is an inline script, event handler, or style — external resources causing a violation will not generate a sample.
- {{domxref("CSPViolationReportBody.sourceFile")}} {{ReadOnlyInline}}
- : If the violation occurred as a result of a script, this will be the URL of the script; otherwise, it will be `null`. Both `columnNumber` and `lineNumber` should have non-null values if this property is not `null`.
- {{domxref("CSPViolationReportBody.statusCode")}} {{ReadOnlyInline}}
- : A number representing the HTTP status code of the document or worker in which the violation occurred.
## Instance methods
_Also inherits methods from its parent interface, {{DOMxRef("ReportBody")}}._
- {{DOMxRef("CSPViolationReportBody.toJSON()")}}
- : A _serializer_ which returns a JSON representation of the `CSPViolationReportBody` object.
## Examples
### Obtaining a `CSPViolationReportBody` object
To obtain a `CSPViolationReportBody` object, you must configure your page so that a CSP violation will occur. In this example, we will set our CSP to only allow content from the site's own origin, and then attempt to load a script from `apis.google.com`, which is an external origin.
First, we will set our {{HTTPHeader("Content-Security-Policy")}} header:
```http
Content-Security-Policy: default-src 'self';
```
Then, we will attempt to load an external script:
```html
<!-- This should generate a CSP violation -->
<script src="https://apis.google.com/js/platform.js"></script>
```
Finally, we will create a new {{domxref("ReportingObserver")}} object to listen for CSP violations.
```js
const observer = new ReportingObserver(
(reports, observer) => {
const cspViolation = reports[0].body;
},
{
types: ["csp-violation"],
buffered: true,
},
);
observer.observe();
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("ReportBody")}}
- {{domxref("ReportingObserver")}}
- {{HTTPHeader("Content-Security-Policy")}}
- {{domxref("SecurityPolicyViolationEvent")}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/domquad/index.md | ---
title: DOMQuad
slug: Web/API/DOMQuad
page-type: web-api-interface
browser-compat: api.DOMQuad
---
{{APIRef("Geometry Interfaces")}}
A `DOMQuad` is a collection of four `DOMPoint`s defining the corners of an arbitrary quadrilateral. Returning `DOMQuad`s lets `getBoxQuads()` return accurate information even when arbitrary 2D or 3D transforms are present. It has a handy `bounds` attribute returning a `DOMRectReadOnly` for those cases where you just want an axis-aligned bounding rectangle.
## Constructor
- {{domxref("DOMQuad.DOMQuad", "DOMQuad()")}}
- : Creates a new `DOMQuad` object.
## Instance properties
- p1,p2,p3,p4 {{ReadOnlyInline}}
- : are {{domxref("DOMPoint")}} objects for each of the `DOMQuad` object's four corners.
## Instance methods
- {{domxref("DOMQuad.fromRect()")}}
- : Returns a new `DOMQuad` object based on the passed set of coordinates.
- {{domxref("DOMQuad.fromQuad()")}}
- : Returns a new `DOMQuad` object based on the passed set of coordinates.
- {{domxref("DOMQuad.getBounds()")}}
- : Returns a {{domxref("DOMRect")}} object with the coordinates and dimensions of the `DOMQuad` object.
- {{domxref("DOMQuad.toJSON()")}}
- : Returns a JSON representation of the `DOMQuad` object.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/svgfeblendelement/index.md | ---
title: SVGFEBlendElement
slug: Web/API/SVGFEBlendElement
page-type: web-api-interface
browser-compat: api.SVGFEBlendElement
---
{{APIRef("SVG")}}
The **`SVGFEBlendElement`** interface corresponds to the {{SVGElement("feBlend")}} element.
{{InheritanceDiagram}}
## Constants
<table class="no-markdown">
<tbody>
<tr>
<th>Name</th>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td><code>SVG_FEBLEND_MODE_UNKNOWN</code></td>
<td>0</td>
<td>
The type is not one of predefined types. It is invalid to attempt to
define a new value of this type or to attempt to switch an existing
value to this type.
</td>
</tr>
<tr>
<td><code>SVG_FEBLEND_MODE_NORMAL</code></td>
<td>1</td>
<td>Corresponds to the value <code>normal</code>.</td>
</tr>
<tr>
<td><code>SVG_FEBLEND_MODE_MULTIPLY</code></td>
<td>2</td>
<td>Corresponds to the value <code>multiply</code>.</td>
</tr>
<tr>
<td><code>SVG_FEBLEND_MODE_SCREEN</code></td>
<td>3</td>
<td>Corresponds to the value <code>screen</code>.</td>
</tr>
<tr>
<td><code>SVG_FEBLEND_MODE_DARKEN</code></td>
<td>4</td>
<td>Corresponds to the value <code>darken</code>.</td>
</tr>
<tr>
<td><code>SVG_FEBLEND_MODE_LIGHTEN</code></td>
<td>5</td>
<td>Corresponds to the value <code>lighten</code>.</td>
</tr>
</tbody>
</table>
## Instance properties
_This interface also inherits properties from its parent interface, {{domxref("SVGElement")}}._
- {{domxref("SVGFEBlendElement.height")}} {{ReadOnlyInline}}
- : An {{domxref("SVGAnimatedLength")}} corresponding to the {{SVGAttr("height")}} attribute of the given element.
- {{domxref("SVGFEBlendElement.in1")}} {{ReadOnlyInline}}
- : An {{domxref("SVGAnimatedString")}} corresponding to the {{SVGAttr("in")}} attribute of the given element.
- {{domxref("SVGFEBlendElement.in2")}} {{ReadOnlyInline}}
- : An {{domxref("SVGAnimatedString")}} corresponding to the {{SVGAttr("in2")}} attribute of the given element.
- {{domxref("SVGFEBlendElement.mode")}} {{ReadOnlyInline}}
- : An {{domxref("SVGAnimatedEnumeration")}} corresponding to the {{SVGAttr("mode")}} attribute of the given element. It takes one of the `SVG_FEBLEND_MODE_*` constants defined on this interface.
- {{domxref("SVGFEBlendElement.result")}} {{ReadOnlyInline}}
- : An {{domxref("SVGAnimatedString")}} corresponding to the {{SVGAttr("result")}} attribute of the given element.
- {{domxref("SVGFEBlendElement.width")}} {{ReadOnlyInline}}
- : An {{domxref("SVGAnimatedLength")}} corresponding to the {{SVGAttr("width")}} attribute of the given element.
- {{domxref("SVGFEBlendElement.x")}} {{ReadOnlyInline}}
- : An {{domxref("SVGAnimatedLength")}} corresponding to the {{SVGAttr("x")}} attribute of the given element.
- {{domxref("SVGFEBlendElement.y")}} {{ReadOnlyInline}}
- : An {{domxref("SVGAnimatedLength")}} corresponding to the {{SVGAttr("y")}} attribute of the given element.
## Instance methods
_This interface does not provide any specific methods, but implements those of its parent, {{domxref("SVGElement")}}._
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{SVGElement("feBlend")}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/documenttimeline/index.md | ---
title: DocumentTimeline
slug: Web/API/DocumentTimeline
page-type: web-api-interface
browser-compat: api.DocumentTimeline
---
{{ APIRef("Web Animations") }}
The **`DocumentTimeline`** interface of the [Web Animations API](/en-US/docs/Web/API/Web_Animations_API) represents animation timelines, including the default document timeline (accessed via {{domxref("Document.timeline")}}).
{{InheritanceDiagram}}
## Constructor
- {{domxref("DocumentTimeline.DocumentTimeline", "DocumentTimeline()")}}
- : Creates a new `DocumentTimeline` object associated with the active document of the current browsing context.
## Instance properties
_This interface inherits its property from its parent, {{domxref("AnimationTimeline")}}._
- {{domxref("AnimationTimeline.currentTime")}}
- : Returns the time value in milliseconds for this timeline or `null` if it is inactive.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Web Animations API](/en-US/docs/Web/API/Web_Animations_API)
- {{domxref("AnimationTimeline")}}
- {{domxref("AnimationTimeline.currentTime")}}
- {{domxref("Document.timeline")}}
- {{domxref("DocumentTimeline.DocumentTimeline", "DocumentTimeline()")}}
| 0 |
data/mdn-content/files/en-us/web/api/documenttimeline | data/mdn-content/files/en-us/web/api/documenttimeline/documenttimeline/index.md | ---
title: "DocumentTimeline: DocumentTimeline() constructor"
short-title: DocumentTimeline()
slug: Web/API/DocumentTimeline/DocumentTimeline
page-type: web-api-constructor
browser-compat: api.DocumentTimeline.DocumentTimeline
---
{{ APIRef("Web Animations") }}
The **`DocumentTimeline()`** constructor of the [Web Animations API](/en-US/docs/Web/API/Web_Animations_API) creates a new instance of the {{domxref("DocumentTimeline")}} object associated with the active document of the current browsing context.
## Syntax
```js-nolint
new DocumentTimeline(options)
```
### Parameters
- `options` {{optional_inline}}
- : An object specifying options for the new timeline. The following properties are available:
- `originTime` {{optional_inline}}
- : A `number` that specifies the zero time for the {{domxref("DocumentTimeline")}}
as a number of milliseconds relative to {{domxref("Performance.timeOrigin")}}.
Defaults to `0`.
## Examples
### Origin time
A {{domxref("DocumentTimeline")}} with an `originTime` of zero counts time
starting from {{domxref("Performance.timeOrigin")}}. This is the same behavior
as {{domxref("Document.timeline")}}.
```js
const timeline = new DocumentTimeline();
console.log(timeline.currentTime === document.timeline.currentTime); // true
```
Setting a non-zero `originTime` will offset the {{domxref("DocumentTimeline")}}
from {{domxref("Document.timeline")}} by that amount:
```js
const offsetTimeline = new DocumentTimeline({ originTime: 500 });
console.log(document.timeline.currentTime - offsetTimeline.currentTime); // 500
```
A {{domxref("DocumentTimeline")}} relative to the current moment can be constructed with:
```js
const nowTimeline = new DocumentTimeline({
originTime: document.timeline.currentTime,
});
console.log(nowTimeline.currentTime); // 0
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Web Animations API](/en-US/docs/Web/API/Web_Animations_API)
- {{domxref("AnimationTimeline")}}
- {{domxref("DocumentTimeline")}}
| 0 |
data/mdn-content/files/en-us/web/api | data/mdn-content/files/en-us/web/api/deprecationreportbody/index.md | ---
title: DeprecationReportBody
slug: Web/API/DeprecationReportBody
page-type: web-api-interface
status:
- experimental
browser-compat: api.DeprecationReportBody
---
{{APIRef("Reporting API")}}{{SeeCompatTable}}
The `DeprecationReportBody` interface of the [Reporting API](/en-US/docs/Web/API/Reporting_API) represents the body of a deprecation report.
A deprecation report is generated when a deprecated feature (for example a deprecated API method) is used on a document being observed by a {{domxref("ReportingObserver")}}. In addition to the support of this API, receiving useful deprecation warnings relies on browser vendors adding these warnings for deprecated features.
{{InheritanceDiagram}}
## Constructor
An instance of `DeprecationReportBody` is returned as the value of {{domxref("Report.body")}} when {{domxref("Report.Type")}} is `deprecation`. The interface has no constructor.
## Instance properties
This interface also inherits properties from {{domxref("ReportBody")}}.
- {{domxref("DeprecationReportBody.id")}} {{experimental_inline}}
- : A string representing the feature or API that is deprecated, for example `NavigatorGetUserMedia`. This can be used to group reports by deprecated feature.
- {{domxref("DeprecationReportBody.anticipatedRemoval")}} {{Experimental_Inline}}
- : A {{jsxref("Date")}} object (rendered as a string) representing the date when the feature is expected to be removed from the current browser. If the date is not known, this property will return `null`.
- {{domxref("DeprecationReportBody.message")}} {{experimental_inline}}
- : A string containing a human-readable description of the deprecation, including information such as what newer feature has superseded it, if any. This typically matches the message a browser will display in its DevTools console when a deprecated feature is used, if one is available.
- {{domxref("DeprecationReportBody.sourceFile")}} {{experimental_inline}}
- : A string containing the path to the source file where the deprecated feature was used, if known, or `null` otherwise.
- {{domxref("DeprecationReportBody.lineNumber")}} {{experimental_inline}}
- : A number representing the line in the source file in which the deprecated feature was used, if known, or `null` otherwise.
- {{domxref("DeprecationReportBody.columnNumber")}} {{experimental_inline}}
- : A number representing the column in the source file in which the deprecated feature was used, if known, or `null` otherwise.
## Instance methods
This interface also inherits methods from {{domxref("ReportBody")}}.
- {{domxref("DeprecationReportBody.toJSON()")}} {{experimental_inline}}
- : A _serializer_ which returns a JSON representation of the `InterventionReportBody` object.
## Examples
In our [deprecation_report.html](https://mdn.github.io/dom-examples/reporting-api/deprecation_report.html) example, we create a simple reporting observer to observe usage of deprecated features on our web page:
```js
const options = {
types: ["deprecation"],
buffered: true,
};
const observer = new ReportingObserver((reports, observer) => {
reportBtn.onclick = () => displayReports(reports);
}, options);
```
We then tell it to start observing reports using {{domxref("ReportingObserver.observe()")}}; this tells the observer to start collecting reports in its report queue, and runs the callback function specified inside the constructor:
```js
observer.observe();
```
Because of the event handler we set up inside the `ReportingObserver()` constructor, we can now click the button to display the report details.
![image of a jolly bearded man with various stats displayed below it about a deprecated feature](reporting_api_example.png)
The report details are displayed via the `displayReports()` function, which takes the observer callback's `reports` parameter as its parameter:
```js
function displayReports(reports) {
const outputElem = document.querySelector(".output");
const list = document.createElement("ul");
outputElem.appendChild(list);
reports.forEach((report, i) => {
const listItem = document.createElement("li");
const textNode = document.createTextNode(
`Report ${i + 1}, type: ${report.type}`,
);
listItem.appendChild(textNode);
const innerList = document.createElement("ul");
listItem.appendChild(innerList);
list.appendChild(listItem);
for (const [key, value] of Object.entries(report.body)) {
const innerListItem = document.createElement("li");
innerListItem.textContent = `${key}: ${value}`;
innerList.appendChild(innerListItem);
}
});
}
```
The `reports` parameter contains an array of all the reports in the observer's report queue. We loop over each report using a basic [`for`](/en-US/docs/Web/JavaScript/Reference/Statements/for) loop, then iterate over each entry of in the report's body (a `DeprecationReportBody` instance) using a [`for...in`](/en-US/docs/Web/JavaScript/Reference/Statements/for...in) structure, displaying each key/value pair inside a list item.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [Reporting API](/en-US/docs/Web/API/Reporting_API)
- [The Reporting API](https://developer.chrome.com/docs/capabilities/web-apis/reporting-api)
| 0 |
data/mdn-content/files/en-us/web/api/deprecationreportbody | data/mdn-content/files/en-us/web/api/deprecationreportbody/columnnumber/index.md | ---
title: "DeprecationReportBody: columnNumber property"
short-title: columnNumber
slug: Web/API/DeprecationReportBody/columnNumber
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.DeprecationReportBody.columnNumber
---
{{APIRef("Reporting API")}}{{SeeCompatTable}}
The **`columnNumber`** read-only property of the {{domxref("DeprecationReportBody")}} interface returns the line in the source file in which the deprecated feature was used.
> **Note:** This property is most useful alongside {{domxref("DeprecationReportBody.sourceFile")}} and {{domxref("DeprecationReportBody.lineNumber")}} as it enables the location of the column in that file and line where the error occurred.
## Value
An integer, or `null` if the column is not known.
## Examples
In this example we create a new {{domxref("ReportingObserver")}} to observe deprecation reports, then print the value of `columnNumber` to the console.
```js
let options = {
types: ["deprecation"],
buffered: true,
};
let observer = new ReportingObserver((reports, observer) => {
let firstReport = reports[0];
console.log(firstReport.type); // deprecation
console.log(firstReport.body.sourceFile); // the source file
console.log(firstReport.body.lineNumber); // the line in that file
console.log(firstReport.body.columnNumber); // the column in that file.
}, options);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/deprecationreportbody | data/mdn-content/files/en-us/web/api/deprecationreportbody/linenumber/index.md | ---
title: "DeprecationReportBody: lineNumber property"
short-title: lineNumber
slug: Web/API/DeprecationReportBody/lineNumber
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.DeprecationReportBody.lineNumber
---
{{APIRef("Reporting API")}}{{SeeCompatTable}}
The **`lineNumber`** read-only property of the {{domxref("DeprecationReportBody")}} interface returns the line in the source file in which the deprecated feature was used.
> **Note:** This property is most useful alongside {{domxref("DeprecationReportBody.sourceFile")}} as it enables the location of the line in that file where the error occurred.
## Value
An integer, or `null` if the line is not known.
## Examples
In this example we create a new {{domxref("ReportingObserver")}} to observe deprecation reports, then print the value of `lineNumber` to the console.
```js
let options = {
types: ["deprecation"],
buffered: true,
};
let observer = new ReportingObserver((reports, observer) => {
let firstReport = reports[0];
console.log(firstReport.type); // deprecation
console.log(firstReport.body.sourceFile); // the source file
console.log(firstReport.body.lineNumber); // the line in that file
}, options);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |
data/mdn-content/files/en-us/web/api/deprecationreportbody | data/mdn-content/files/en-us/web/api/deprecationreportbody/message/index.md | ---
title: "DeprecationReportBody: message property"
short-title: message
slug: Web/API/DeprecationReportBody/message
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.DeprecationReportBody.message
---
{{APIRef("Reporting API")}}{{SeeCompatTable}}
The **`message`** read-only property of the {{domxref("DeprecationReportBody")}} interface returns a human-readable description of the deprecation. This typically matches the message a browser will display in its DevTools console regarding a deprecated feature.
## Value
A string.
## Examples
In this example we create a new {{domxref("ReportingObserver")}} to observe deprecation reports, then print the value of `message` to the console.
```js
let options = {
types: ["deprecation"],
buffered: true,
};
let observer = new ReportingObserver((reports, observer) => {
let firstReport = reports[0];
console.log(firstReport.type); // deprecation
console.log(firstReport.body.message);
}, options);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
| 0 |