Input
✅️️ Methods
🔨Input.cancelDragging
取消页面中任何正在进行的拖拽操作。
EN
Cancels any active dragging in the page.
🔨Input.dispatchKeyEvent
向页面发送一个按 键事件。
EN
Dispatches a key event to the page.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| type | ✔️ | string | 按键事件的类型。 允许的值: keyDown、keyUp、rawKeyDown、char | ENType of the key event.Allowed Values: keyDown, keyUp, rawKeyDown, char | |
| modifiers | integer | 表示按下的修饰键的位字段。Alt=1、Ctrl=2、Meta/Command=4、Shift=8(默认值:0)。 | ENBit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0). | ||
| timestamp | TimeSinceEpoch | 事件发生的时间。 | ENTime at which the event occurred. | ||
| text | string | 通过键盘布局处理虚拟键码生成的文本。对于 keyUp 和 rawKeyDown 事件不需要(默认:"") | ENText as generated by processing a virtual key code with a keyboard layout. Not needed for forkeyUp and rawKeyDown events (default: "") | ||
| unmodifiedText | string | 如果没有按下任何修饰键(除了Shift键),键盘本应生成的文本。适用于快捷键(加速器)键处理(默认:"")。 | ENText that would have been generated by the keyboard if no modifiers were pressed (except for shift). Useful for shortcut (accelerator) key handling (default: ""). | ||
| keyIdentifier | string | 唯一键标识符(例如,'U+0041')(默认:"")。 | ENUnique key identifier (e.g., 'U+0041') (default: ""). | ||
| code | string | 每个物理键的唯一DOM定义字符串值(例如,'KeyA')(默认值:"")。 | ENUnique DOM defined string value for each physical key (e.g., 'KeyA') (default: ""). | ||
| key | string | 描述键在活动修饰键、键盘布局等上下文中的含义的唯一DOM定义字符串值(例如,'AltGr')(默认:"")。 | ENUnique DOM defined string value describing the meaning of the key in the context of active modifiers, keyboard layout, etc (e.g., 'AltGr') (default: ""). | ||
| windowsVirtualKeyCode | integer | Windows virtual key code (default: 0). | ENWindows virtual key code (default: 0). | ||
| nativeVirtualKeyCode | integer | 原生虚拟键码(默认值:0)。 | ENNative virtual key code (default: 0). | ||
| autoRepeat | boolean | 事件是否由自动重复生成(默认值:false)。 | ENWhether the event was generated from auto repeat (default: false). | ||
| isKeypad | boolean | 事件是否由键盘生成(默认值:false)。 | ENWhether the event was generated from the keypad (default: false). | ||
| isSystemKey | boolean | 事件是否为系统按键事件(默认值:false)。 | ENWhether the event was a system key event (default: false). | ||
| location | integer | 事件来自键盘的左侧还是右侧。1=左侧,2=右侧(默认值:0)。 | ENWhether the event was from the left or right side of the keyboard. 1=Left, 2=Right (default: 0). | ||
| commands | 🧪 | array[string] | 随按键事件发送的编辑命令(例如 'selectAll')(默认值:[])。这些命令与 document.execCommand 和 NSStandardKeyBindingResponding 中使用的命令名称相关但不完全相同。有效命令名称请参阅 https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h。 | ENEditing commands to send with the key event (e.g., 'selectAll') (default: []). These are related to but not equal the command names used indocument.execCommand and NSStandardKeyBindingResponding. See https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h for valid command names. |
🔨Input.dispatchMouseEvent
向页面分发一个鼠标事件。
EN
Dispatches a mouse event to the page.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| type | ✔️ | string | 鼠标事件的类型。 允许的值: mousePressed、mouseReleased、mouseMoved、mouseWheel | ENType of the mouse event.Allowed Values: mousePressed, mouseReleased, mouseMoved, mouseWheel | |
| x | ✔️ | number | 事件相对于主框架视口的X坐标,以CSS像素为单位。 | ENX coordinate of the event relative to the main frame's viewport in CSS pixels. | |
| y | ✔️ | number | 事件相对于主框架视口的Y坐标,以CSS像素为单位。0表示视口顶部,Y值随着向视口底部移动而增加。 | ENY coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport. | |
| modifiers | integer | 表示按下的修饰键的位字段。Alt=1,Ctrl=2,Meta/Command=4,Shift=8(默认值:0)。 | ENBit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0). | ||
| timestamp | TimeSinceEpoch | 事件发生的时间。 | ENTime at which the event occurred. | ||
| button | MouseButton | 鼠标按钮(默认值:"none")。 | ENMouse button (default: "none"). | ||
| buttons | integer | 一个数字,表示鼠标事件触发时按下了哪些鼠标按钮。Left=1, Right=2, Middle=4, Back=8, Forward=16, None=0。 | ENA number indicating which buttons are pressed on the mouse when a mouse event is triggered. Left=1, Right=2, Middle=4, Back=8, Forward=16, None=0. | ||
| clickCount | integer | 鼠标按钮被点击的次数(默认值:0)。 | ENNumber of times the mouse button was clicked (default: 0). | ||
| force | 🧪 | number | 标准化压力,其范围为[0,1](默认值:0)。 | ENThe normalized pressure, which has a range of [0,1] (default: 0). | |
| tangentialPressure | 🧪 | number | 归一化的切向压力,其取值范围为[-1,1](默认值:0)。 | ENThe normalized tangential pressure, which has a range of [-1,1] (default: 0). | |
| tiltX | number | Y-Z平面与包含触控笔轴线和Y轴的平面之间的平面角,以度为单位,范围在[-90,90]之间,正的tiltX表示向右倾斜(默认值:0)。 | ENThe plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0). | ||
| tiltY | number | X-Z平面与包含触控笔轴线和X轴的平面之间的平面角,以度为单位,范围在[-90,90]之间,正倾斜角朝向用户(默认值:0)。 | ENThe plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0). | ||
| twist | 🧪 | integer | 笔触围绕其自身主轴顺时针旋转的角度,以度为单位,范围在[0,359]之间(默认值:0)。 | ENThe clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0). | |
| deltaX | number | 鼠标滚轮事件的 X 轴增量(以 CSS 像素为单位)(默认值:0)。 | ENX delta in CSS pixels for mouse wheel event (default: 0). | ||
| deltaY | number | CSS像素中的鼠标滚轮事件Y增量(默认值:0)。 | ENY delta in CSS pixels for mouse wheel event (default: 0). | ||
| pointerType | string | 指针类型(默认:"mouse")。 允许取值: mouse、pen | ENPointer type (default: "mouse").Allowed Values: mouse, pen |
🔨Input.dispatchTouchEvent
向页面分发一个触摸事件。
EN
Dispatches a touch event to the page.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| type | ✔️ | string | 触摸事件的类型。TouchEnd和TouchCancel不得包含任何触摸点,而TouchStart和TouchMove必须至少包含一个触摸点。 允许的值: touchStart、touchEnd、touchMove、touchCancel | ENType of the touch event. TouchEnd and TouchCancel must not contain any touch points, while TouchStart and TouchMove must contains at least one.Allowed Values: touchStart, touchEnd, touchMove, touchCancel | |
| touchPoints | ✔️ | array[TouchPoint] | 触摸设备上的活动接触点。每个序列中相对于前一个触摸事件发生变化的点都会生成一个事件,模拟逐个按下/移动/释放接触点的过程。 | ENActive touch points on the touch device. One event per any changed point (compared to previous touch event in a sequence) is generated, emulating pressing/moving/releasing points one by one. | |
| modifiers | integer | 表示按下的修饰键的位字段。Alt=1、Ctrl=2、Meta/Command=4、Shift=8(默认值:0)。 | ENBit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0). | ||
| timestamp | TimeSinceEpoch | 事件发生的时间。 | ENTime at which the event occurred. |
🔨Input.setIgnoreInputEvents
忽略输入事件(在审核页面时很有用)。
EN
Ignores input events (useful while auditing page).
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| ignore | ✔️ | boolean | 当设置为true时,忽略输入事件处理。 | ENIgnores input events processing when set to true. |
🔨Input.dispatchDragEvent🧪
向页面中分派一个拖拽事件。
EN
Dispatches a drag event into the page.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| type | ✔️ | string | 拖拽事件的类型。 允许的取值: dragEnter、dragOver、drop、dragCancel | ENType of the drag event.Allowed Values: dragEnter, dragOver, drop, dragCancel | |
| x | ✔️ | number | 事件相对于主框架视口的X坐标,以CSS像素为单位。 | ENX coordinate of the event relative to the main frame's viewport in CSS pixels. | |
| y | ✔️ | number | 事件相对于主框架视口的Y坐标,以CSS像素为单位。0表示视口顶部,Y值随着向视口底部移动而增加。 | ENY coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport. | |
| data | ✔️ | DragData | |||
| modifiers | integer | 表示按下的修饰键的位字段。Alt=1,Ctrl=2,Meta/Command=4,Shift=8(默认值:0)。 | ENBit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0). |
🔨Input.emulateTouchFromMouseEvent🧪
模拟来自鼠标事件参数的触摸事件。
EN
Emulates touch event from the mouse event parameters.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| type | ✔️ | string | 鼠标事件的类型。 允许的值: mousePressed、mouseReleased、mouseMoved、mouseWheel | ENType of the mouse event.Allowed Values: mousePressed, mouseReleased, mouseMoved, mouseWheel | |
| x | ✔️ | integer | 鼠标指针在DIP中的X坐标。 | ENX coordinate of the mouse pointer in DIP. | |
| y | ✔️ | integer | 鼠标指针在DIP中的Y坐标。 | ENY coordinate of the mouse pointer in DIP. | |
| button | ✔️ | MouseButton | 鼠标按钮。仅支持 "none"、"left"、"right"。 | ENMouse button. Only "none", "left", "right" are supported. | |
| timestamp | TimeSinceEpoch | 事件发生的时间(默认:当前时间)。 | ENTime at which the event occurred (default: current time). | ||
| deltaX | number | X delta in DIP for mouse wheel event (default: 0). | ENX delta in DIP for mouse wheel event (default: 0). | ||
| deltaY | number | 鼠标滚轮事件的 DIP 中的 Y 增量(默认值:0)。 | ENY delta in DIP for mouse wheel event (default: 0). | ||
| modifiers | integer | 表示按下的修饰键的位字段。Alt=1、Ctrl=2、Meta/Command=4、Shift=8(默认值:0)。 | ENBit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0). | ||
| clickCount | integer | 鼠标按钮被点击的次数(默认值:0)。 | ENNumber of times the mouse button was clicked (default: 0). |
🔨Input.imeSetComposition🧪
此方法设置输入法编辑器(IME)的当前候选文本。使用 imeCommitComposition 提交最终文本。通过调用 imeSetComposition 并将文本参数设为空字符串来取消组合输入。
EN
This method sets the current candidate text for IME. Use imeCommitComposition to commit the final text. Use imeSetComposition with empty string as text to cancel composition.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| text | ✔️ | string | 要插入的文本 | ENThe text to insert | |
| selectionStart | ✔️ | integer | 选择起始点 | ENselection start | |
| selectionEnd | ✔️ | integer | 选择结束 | ENselection end | |
| replacementStart | integer | 替换开始 | ENreplacement start | ||
| replacementEnd | integer | 替换结束 | ENreplacement end |
🔨Input.insertText🧪
该方法模拟插入并非来自按键的文本,例如表情符号键盘或输入法。
EN
This method emulates inserting text that doesn't come from a key press, for example an emoji keyboard or an IME.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| text | ✔️ | string | 要插入的文本。 | ENThe text to insert. |
🔨Input.setInterceptDrags🧪
阻止默认的拖放行为,并改为发出 Input.dragIntercepted 事件。拖放行为可以通过 Input.dispatchDragEvent 直接控制。
EN
Prevents default drag and drop behavior and instead emits
Input.dragIntercepted events. Drag and drop behavior can be directly controlled via Input.dispatchDragEvent.| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| enabled | ✔️ | boolean |
🔨Input.synthesizePinchGesture🧪
通过发出适当的触摸事件,在一段时间内合成捏合手势。
EN
Synthesizes a pinch gesture over a time period by issuing appropriate touch events.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| x | ✔️ | number | 手势起始点的X坐标,单位为CSS像素。 | ENX coordinate of the start of the gesture in CSS pixels. | |
| y | ✔️ | number | 手势起始点的Y坐标,以CSS像素为单位。 | ENY coordinate of the start of the gesture in CSS pixels. | |
| scaleFactor | ✔️ | number | 缩放后的相对比例因子(>1.0 表示放大,<1.0 表示缩小)。 | ENRelative scale factor after zooming (>1.0 zooms in, <1.0 zooms out). | |
| relativeSpeed | integer | 相对指针速度,单位为像素每秒(默认值:800)。 | ENRelative pointer speed in pixels per second (default: 800). | ||
| gestureSourceType | GestureSourceType | 要生成哪种类型的输入事件(默认值:'default',这会向平台查询首选的输入类型)。 | ENWhich type of input events to be generated (default: 'default', which queries the platform for the preferred input type). |
🔨Input.synthesizeScrollGesture🧪
通过发出适当的触摸事件,在一段时间内合成滚动手势。
EN
Synthesizes a scroll gesture over a time period by issuing appropriate touch events.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| x | ✔️ | number | 手势起始点的X坐标,以CSS像素为单位。 | ENX coordinate of the start of the gesture in CSS pixels. | |
| y | ✔️ | number | 手势起始点的Y坐标,以CSS像素为单位。 | ENY coordinate of the start of the gesture in CSS pixels. | |
| xDistance | number | 沿X轴滚动的距离(正数表示向左滚动)。 | ENThe distance to scroll along the X axis (positive to scroll left). | ||
| yDistance | number | 沿Y轴滚动的距离(向上滚动为正)。 | ENThe distance to scroll along the Y axis (positive to scroll up). | ||
| xOverscroll | number | 沿X轴额外滚动的像素数,在给定距离之外。 | ENThe number of additional pixels to scroll back along the X axis, in addition to the given distance. | ||
| yOverscroll | number | 在Y轴上除了给定距离外,额外滚动的像素数量。 | ENThe number of additional pixels to scroll back along the Y axis, in addition to the given distance. | ||
| preventFling | boolean | 防止快速滑动(默认值:true)。 | ENPrevent fling (default: true). | ||
| speed | integer | 滑动速度,单位为像素每秒(默认值:800)。 | ENSwipe speed in pixels per second (default: 800). | ||
| gestureSourceType | GestureSourceType | 要生成哪种类型的输入事件(默认值为 'default',该选项会查询平台以获取首选输入类型)。 | ENWhich type of input events to be generated (default: 'default', which queries the platform for the preferred input type). | ||
| repeatCount | integer | 手势重复次数(默认值:0)。 | ENThe number of times to repeat the gesture (default: 0). | ||
| repeatDelayMs | integer | 每次重复之间的延迟毫秒数。(默认值:250)。 | ENThe number of milliseconds delay between each repeat. (default: 250). | ||
| interactionMarkerName | string | 要生成的交互标记的名称,如果不为空(默认:"")。 | ENThe name of the interaction markers to generate, if not empty (default: ""). |
🔨Input.synthesizeTapGesture🧪
通过发布适当的触摸事件,在一段时间内合成一个点击手势。
EN
Synthesizes a tap gesture over a time period by issuing appropriate touch events.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| x | ✔️ | number | 手势起始点的X坐标,以CSS像素为单位。 | ENX coordinate of the start of the gesture in CSS pixels. | |
| y | ✔️ | number | 手势起始点的Y坐标,以CSS像素为单位。 | ENY coordinate of the start of the gesture in CSS pixels. | |
| duration | integer | 从触地到抬起事件之间的持续时间(以毫秒为单位)(默认值:50)。 | ENDuration between touchdown and touchup events in ms (default: 50). | ||
| tapCount | integer | 执行点击操作的次数(例如,2 表示双击,默认值:1)。 | ENNumber of times to perform the tap (e.g. 2 for double tap, default: 1). | ||
| gestureSourceType | GestureSourceType | 要生成哪种类型的输入事件(默认值:'default',即向平台查询首选输入类型)。 | ENWhich type of input events to be generated (default: 'default', which queries the platform for the preferred input type). |
✅️️ Events
👋Input.dragIntercepted🧪
仅当启用 Input.setInterceptDrags 时才会发出。使用此数据配合 Input.dispatchDragEvent 可恢复正常拖放行为。
EN
Emitted only when
Input.setInterceptDrags is enabled. Use this data with Input.dispatchDragEvent to restore normal drag and drop behavior.| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| data | ✔️ | DragData |
✅️️ Types
📌Input.MouseButton
允许的值:none、left、middle、right、back、forward
EN
Allowed Values:
none, left, middle, right, back, forward返回类型:string
📌Input.TimeSinceEpoch
自1970年1月1日起计算的UTC时间(秒数)。
EN
UTC time in seconds, counted from January 1, 1970.
返回类型:number
📌Input.TouchPoint
返回类型:object
| 属性 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| x | ✔️ | number | 事件相对于主框架视口的X坐标,以CSS像素为单位。 | ENX coordinate of the event relative to the main frame's viewport in CSS pixels. | |
| y | ✔️ | number | 事件相对于主框架视口的Y坐标,以CSS像素为单位。0表示视口顶部,Y值向下移动时逐渐增大。 | ENY coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport. | |
| radiusX | number | 触摸区域的X半径(默认值:1.0)。 | ENX radius of the touch area (default: 1.0). | ||
| radiusY | number | 触摸区域的Y轴半径(默认值:1.0)。 | ENY radius of the touch area (default: 1.0). | ||
| rotationAngle | number | 旋转角度(默认值:0.0)。 | ENRotation angle (default: 0.0). | ||
| force | number | Force (默认值: 1.0)。 | ENForce (default: 1.0). | ||
| tangentialPressure | 🧪 | number | 归一化的切向压力,其取值范围为[-1,1](默认值:0)。 | ENThe normalized tangential pressure, which has a range of [-1,1] (default: 0). | |
| tiltX | number | Y-Z平面与包含触控笔轴线和Y轴的平面之间的平面角,以度为单位,范围[-90,90],正的tiltX表示向右倾斜(默认值:0) | ENThe plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0) | ||
| tiltY | number | X-Z平面与包含触控笔轴线和X轴的平面之间的平面角,以[-90,90]度范围内的度数表示,正的tiltY朝向用户(默认值:0)。 | ENThe plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0). | ||
| twist | 🧪 | integer | 笔触围绕其自身主轴顺时针旋转的角度,以度为单位,范围在[0,359]之间(默认值:0)。 | ENThe clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0). | |
| id | number | 用于在事件之间追踪触摸源的标识符,必须在单个事件中保持唯一。 | ENIdentifier used to track touch sources between events, must be unique within an event. |
📌Input.DragData🧪
返回类型:object
| 属性 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| items | ✔️ | array[DragDataItem] | |||
| files | array[string] | 拖放时应包含的文件名列表 | ENList of filenames that should be included when dropping | ||
| dragOperationsMask | ✔️ | integer | 表示允许的拖拽操作的位字段。Copy = 1, Link = 2, Move = 16 | ENBit field representing allowed drag operations. Copy = 1, Link = 2, Move = 16 |
📌Input.DragDataItem🧪
返回类型:object
| 属性 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| mimeType | ✔️ | string | 被拖动数据的MIME类型。 | ENMime type of the dragged data. | |
| data | ✔️ | string | 根据mimeType的值,它包含被拖动的链接、文本、HTML标记或任何其他数据。 | ENDepending of the value ofmimeType, it contains the dragged link, text, HTML markup or any other data. | |
| title | string | 链接关联的标题。仅在 mimeType == "text/uri-list" 时有效。 | ENTitle associated with a link. Only valid whenmimeType == "text/uri-list". | ||
| baseURL | string | 存储包含标记的基础URL。仅在 mimeType == "text/html" 时有效。 | ENStores the base URL for the contained markup. Only valid whenmimeType == "text/html". |
📌Input.GestureSourceType🧪
允许的值:default、touch、mouse
EN
Allowed Values:
default, touch, mouse返回类型:string