我正在为 Galaxy Tab S3 开发一个网络应用程序,允许用户使用三星 S-Pen 进行绘图。 S-Pen 侧面有一个按钮,我知道原生 Android 应用程序可以使用该按钮来执行各种功能。但是,我很难弄清楚如何确定按下此按钮时(或者即使事件被触发?)在浏览器中触发哪个事件。
我已经尝试了所有
PointerEvents
和 TouchEvents
,并尝试在这里识别一个事件:https://patrickhlauke.github.io/touch/
我在S-Pen SDK中也没有发现任何东西: https://developer.samsung.com/galaxy-spen-remote/overview.html
不幸的是这篇文章被删除了: https://stackoverflow.com/questions/51489489/detecting-pen-stylus-button-events-in-javascript
有人知道该活动的名称或者我可以在哪里找到它吗?
我在任何地方都没有找到任何文档。来自我的 Galaxy 平板电脑上 Chrome 中的按钮实用性实验:
检测屏幕上方“空中”按下的按钮:
element.onpointermove = e => {
//screen-contact registers as the primary button.
//primary button with zero screen contact implies the S-Pen button
if( e.button === 1 && e.pressure === 0 )
console.log( "The S-Pen button is being pressed in the air." );
}
当在空中按下 S-Pen 按钮,然后手写笔接触屏幕,然后离开屏幕时,Chrome 会触发 contextmenu 事件。 (据我通过搜索设置找到的,行为不能被修改。)
element.oncontextmenu = e => {
console.log( "The S-Pen button was being pressed, the stylus made contact with the screen, and then the stylus lost contact with the screen." );
}
如果在手写笔与屏幕接触时按下 S-Pen 按钮,浏览器将完全停止触发指针事件,直到手写笔与屏幕失去接触,即使在接触过程中释放了 S-Pen 按钮。
这使得开发利用 S-Pen 按钮的绘画应用程序几乎不可能。不过,只要用户不触摸屏幕,就可以使用 S-Pen 坐标和按钮状态。
如果有人提供文档,我们将不胜感激。我半怀疑代码交互已经消失,目前三星和谷歌没有工程师或开发人员知道他们的代码在这里做什么。