javascript - Android 上的 Chrome 按键事件报告很有趣
问题描述
我在带有输入框的 Android (86.0.4240.99) 上使用 Chrome 时遇到问题。基本上,我正在听 keydown 事件并操作文本框,所以感觉更像是一个计算器条目/应用输入掩码,因为他们用逗号等键入。
对于我的输入:
type="text"
pattern="[0-9]*"
inputmode="decimal"
在按下“.”时的 keydown 事件中,事件对象很奇怪,键为“未识别”,键码为 229(逗号的作用完全相同)。这些数字似乎工作正常,只是键盘上出现的“,”,“。”和“-”按钮可以做到这一点。通过我手动操作输入的方式,我需要知道小数点何时被点击,但我无法区分。
这是 KeboardEvent 对象:
{ altKey: false
bubbles: true
cancelBubble: false
cancelable: true
charCode: 0
code: ""
composed: true
ctrlKey: false
currentTarget: null
defaultPrevented: true
detail: 0
eventPhase: 0
isComposing: false
isTrusted: true
key: "Unidentified"
keyCode: 229
location: 0
metaKey: false
path: (22) [input#input-518, div.v-text-field__slot, div.v-input__slot, div.v-input__control, div.v-input.v-input--is-label-active.v-input--is-dirty.v-input--is-focused.theme--light.v-text-fiel…, div.col, div.row, div, div.container, div.v-window-item.v-window-item--active, div.v-window__container, div.v-window.v-item-group.theme--light.v-tabs-items, div.v-tabs.v-tabs--grow.theme--light, div.v-card__text, div#tasks.v-card.v-sheet.theme--light, div.v-dialog.v-dialog--active.v-dialog--persistent, div.v-dialog__content.v-dialog__content--active, div#app.v-application.v-application--is-ltr.theme--light, body, html.overflow-y-hidden, document, Window]
repeat: false
returnValue: false
shiftKey: false
sourceCapabilities: InputDeviceCapabilities {firesTouchEvents: false}
srcElement: input#input-518
target: input#input-518
timeStamp: 489740.7000000003
type: "keydown"
view: Window {window: Window, self: Window, document: document, name: "", location: Location, …}
which: 229
}
有没有人遇到过这个或知道如何解决它?它是 chrome for android 中的错误吗?它在 Chrome for windows 和 iOS 上都能完美运行。
解决方案
推荐阅读
- docker - 如何使用 Docker-Compose 中的 URL 访问服务
- r - 如何在 R 中重新分配变量名?
- linux - 如何安全地将主机列表添加到 known_hosts 文件
- javascript - 单击提交按钮时委托发送(jQuery)
- labview - LabVIEW上的条件并行
- java - 从 POST webview 中提取 HTML 内容 - Java
- neovim - 你如何使用
使用 ALE 循环浏览完成建议? - c# - C# 肥皂请求
- visual-studio-2017 - 在 PackageReference 中使用通配符时,依赖项上的黄色三角形符号没有错误
- python - 熊猫选择要绘制的列