简体   繁体   English

如何使用Webapp处理事件?

[英]How to handle events with a webapp?

I develop a WebApp for a special tablet. 我为特殊的平板电脑开发了WebApp。 On this tablet an embedded linux is the operating system. 在此平板电脑上,嵌入式Linux是操作系统。 The tablet provides four keys which can be additionally used for inputs. 数位板提供四个键,这些键可另外用于输入。 The input of these keys can be tracked by reading /dev/input/event0 . 可以通过读取/dev/input/event0来跟踪这些键的/dev/input/event0 Now I want to use JavaScript to handle these events and trigger events in the WebApp. 现在,我想使用JavaScript处理这些事件并触发WebApp中的事件。 How can I handle such events in JavaScript? 如何在JavaScript中处理此类事件? Is this possible to handle such kind of events? 是否可以处理此类事件?

The technology you need is called WebSocket . 您需要的技术称为WebSocket As soon as your browser/WebApp connects to the server, a bidirectional channel is established, so that server can asynchronously send data to the browser. 一旦您的浏览器/ WebApp连接到服务器,就会建立双向通道,以便服务器可以将数据异步发送到浏览器。 This way you can send your key events and your WebApp can react to them in "real-time". 这样,您可以发送关键事件,并且WebApp可以“实时”响应它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM