跳到主要内容

Input

✅️️ Methods

🔨Input.cancelDragging

取消页面中任何正在进行的拖拽操作。

EN
Cancels any active dragging in the page.

🔨Input.dispatchKeyEvent

向页面发送一个按键事件。

EN
Dispatches a key event to the page.
参数必填标记类型描述原文
type✔️string按键事件的类型。
允许的值:keyDownkeyUprawKeyDownchar
ENType of the key event.
Allowed Values: keyDown, keyUp, rawKeyDown, char
modifiersinteger表示按下的修饰键的位字段。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).
timestampTimeSinceEpoch事件发生的时间。
ENTime at which the event occurred.
textstring通过键盘布局处理虚拟键码生成的文本。对于 keyUprawKeyDown 事件不需要(默认:"")
ENText as generated by processing a virtual key code with a keyboard layout. Not needed for for keyUp and rawKeyDown events (default: "")
unmodifiedTextstring如果没有按下任何修饰键(除了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: "").
keyIdentifierstring唯一键标识符(例如,'U+0041')(默认:"")。
ENUnique key identifier (e.g., 'U+0041') (default: "").
codestring每个物理键的唯一DOM定义字符串值(例如,'KeyA')(默认值:"")。
ENUnique DOM defined string value for each physical key (e.g., 'KeyA') (default: "").
keystring描述键在活动修饰键、键盘布局等上下文中的含义的唯一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: "").
windowsVirtualKeyCodeintegerWindows virtual key code (default: 0).
ENWindows virtual key code (default: 0).
nativeVirtualKeyCodeinteger原生虚拟键码(默认值:0)。
ENNative virtual key code (default: 0).
autoRepeatboolean事件是否由自动重复生成(默认值:false)。
ENWhether the event was generated from auto repeat (default: false).
isKeypadboolean事件是否由键盘生成(默认值:false)。
ENWhether the event was generated from the keypad (default: false).
isSystemKeyboolean事件是否为系统按键事件(默认值:false)。
ENWhether the event was a system key event (default: false).
locationinteger事件来自键盘的左侧还是右侧。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 in document.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鼠标事件的类型。
允许的值:mousePressedmouseReleasedmouseMovedmouseWheel
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.
modifiersinteger表示按下的修饰键的位字段。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).
timestampTimeSinceEpoch事件发生的时间。
ENTime at which the event occurred.
buttonMouseButton鼠标按钮(默认值:"none")。
ENMouse button (default: "none").
buttonsinteger一个数字,表示鼠标事件触发时按下了哪些鼠标按钮。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.
clickCountinteger鼠标按钮被点击的次数(默认值: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).
tiltXnumberY-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).
tiltYnumberX-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).
deltaXnumber鼠标滚轮事件的 X 轴增量(以 CSS 像素为单位)(默认值:0)。
ENX delta in CSS pixels for mouse wheel event (default: 0).
deltaYnumberCSS像素中的鼠标滚轮事件Y增量(默认值:0)。
ENY delta in CSS pixels for mouse wheel event (default: 0).
pointerTypestring指针类型(默认:"mouse")。
允许取值:mousepen
ENPointer type (default: "mouse").
Allowed Values: mouse, pen

🔨Input.dispatchTouchEvent

向页面分发一个触摸事件。

EN
Dispatches a touch event to the page.
参数必填标记类型描述原文
type✔️string触摸事件的类型。TouchEnd和TouchCancel不得包含任何触摸点,而TouchStart和TouchMove必须至少包含一个触摸点。

允许的值:touchStarttouchEndtouchMovetouchCancel
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.
modifiersinteger表示按下的修饰键的位字段。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).
timestampTimeSinceEpoch事件发生的时间。
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拖拽事件的类型。
允许的取值:dragEnterdragOverdropdragCancel
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
modifiersinteger表示按下的修饰键的位字段。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鼠标事件的类型。
允许的值:mousePressedmouseReleasedmouseMovedmouseWheel
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.
timestampTimeSinceEpoch事件发生的时间(默认:当前时间)。
ENTime at which the event occurred (default: current time).
deltaXnumberX delta in DIP for mouse wheel event (default: 0).
ENX delta in DIP for mouse wheel event (default: 0).
deltaYnumber鼠标滚轮事件的 DIP 中的 Y 增量(默认值:0)。
ENY delta in DIP for mouse wheel event (default: 0).
modifiersinteger表示按下的修饰键的位字段。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).
clickCountinteger鼠标按钮被点击的次数(默认值: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
replacementStartinteger替换开始
ENreplacement start
replacementEndinteger替换结束
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).
relativeSpeedinteger相对指针速度,单位为像素每秒(默认值:800)。
ENRelative pointer speed in pixels per second (default: 800).
gestureSourceTypeGestureSourceType要生成哪种类型的输入事件(默认值:'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.
xDistancenumber沿X轴滚动的距离(正数表示向左滚动)。
ENThe distance to scroll along the X axis (positive to scroll left).
yDistancenumber沿Y轴滚动的距离(向上滚动为正)。
ENThe distance to scroll along the Y axis (positive to scroll up).
xOverscrollnumber沿X轴额外滚动的像素数,在给定距离之外。
ENThe number of additional pixels to scroll back along the X axis, in addition to the given distance.
yOverscrollnumber在Y轴上除了给定距离外,额外滚动的像素数量。
ENThe number of additional pixels to scroll back along the Y axis, in addition to the given distance.
preventFlingboolean防止快速滑动(默认值:true)。
ENPrevent fling (default: true).
speedinteger滑动速度,单位为像素每秒(默认值:800)。
ENSwipe speed in pixels per second (default: 800).
gestureSourceTypeGestureSourceType要生成哪种类型的输入事件(默认值为 'default',该选项会查询平台以获取首选输入类型)。
ENWhich type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
repeatCountinteger手势重复次数(默认值:0)。
ENThe number of times to repeat the gesture (default: 0).
repeatDelayMsinteger每次重复之间的延迟毫秒数。(默认值:250)。
ENThe number of milliseconds delay between each repeat. (default: 250).
interactionMarkerNamestring要生成的交互标记的名称,如果不为空(默认:"")。
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.
durationinteger从触地到抬起事件之间的持续时间(以毫秒为单位)(默认值:50)。
ENDuration between touchdown and touchup events in ms (default: 50).
tapCountinteger执行点击操作的次数(例如,2 表示双击,默认值:1)。
ENNumber of times to perform the tap (e.g. 2 for double tap, default: 1).
gestureSourceTypeGestureSourceType要生成哪种类型的输入事件(默认值:'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

允许的值:noneleftmiddlerightbackforward

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.
radiusXnumber触摸区域的X半径(默认值:1.0)。
ENX radius of the touch area (default: 1.0).
radiusYnumber触摸区域的Y轴半径(默认值:1.0)。
ENY radius of the touch area (default: 1.0).
rotationAnglenumber旋转角度(默认值:0.0)。
ENRotation angle (default: 0.0).
forcenumberForce (默认值: 1.0)。
ENForce (default: 1.0).
tangentialPressure🧪number归一化的切向压力,其取值范围为[-1,1](默认值:0)。
ENThe normalized tangential pressure, which has a range of [-1,1] (default: 0).
tiltXnumberY-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)
tiltYnumberX-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).
idnumber用于在事件之间追踪触摸源的标识符,必须在单个事件中保持唯一。
ENIdentifier used to track touch sources between events, must be unique within an event.

📌Input.DragData🧪

返回类型:object

属性必填标记类型描述原文
items✔️array[DragDataItem]
filesarray[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 of mimeType, it contains the dragged link, text, HTML markup or any other data.
titlestring链接关联的标题。仅在 mimeType == "text/uri-list" 时有效。
ENTitle associated with a link. Only valid when mimeType == "text/uri-list".
baseURLstring存储包含标记的基础URL。仅在 mimeType == "text/html" 时有效。
ENStores the base URL for the contained markup. Only valid when mimeType == "text/html".

📌Input.GestureSourceType🧪

允许的值:defaulttouchmouse

EN
Allowed Values: default, touch, mouse

返回类型:string