javascript - What is the use case for navigator.keyboard.lock()navigator.keyboard.unlock()? - Stack Overflow

I was looking through the MDN Web APIs, and I stumbled across navigator.keyboard.I could see a use fo

I was looking through the MDN Web APIs, and I stumbled across navigator.keyboard. I could see a use for Keyboard.getLayoutMap(), with setting up controls for games, or fingerprinting, however, I could not think of a use for Keyboard.lock() / .unlock(). From the MDN Web Docs,

Keyboard.lock() Experimental The lock() method of the Keyboard interface returns a Promise that resolves after enabling the capture of keypresses for any or all of the keys on the physical keyboard. This method can only capture keys that are granted access by the underlying operating system. If lock() is called multiple times then only the key codes specified in the most recent call will be locked. Any keys locked by a previous call to lock() are unlocked.

From this, I made the assumption that it would lock key presses from being registered, but upon setting this simple setup, I saw the keys were still being registered.

<input>
<script>navigator.keyboard.lock()</script>

I know that these are still experimental, and are subject to change, but could anyone elaborate on how to use Keyboard.lock() and what use cases it has.

I searched online, but the only thing I could find for Keyboard.lock() was the MDN Web Doc itself.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744197959a4562744.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信