問題描述
我正在使用 JavaScript、node.js 和 Electron 構(gòu)建一個(gè)應(yīng)用程序.
I am building an application using JavaScript, node.js, and Electron.
此應(yīng)用程序的一部分旨在鎖定計(jì)算機(jī),直到用戶進(jìn)行身份驗(yàn)證.
Part of this application is designed to lock the computer until the user authenticates themselves.
這可行,但是我需要讓我的應(yīng)用程序禁用 alt + tab 鍵盤快捷鍵,因?yàn)槟壳坝脩艨梢允褂盟鼇?lái)跳過(guò)我的鎖定頁(yè)面(并且從而能夠在沒有經(jīng)過(guò)身份驗(yàn)證的情況下使用計(jì)算機(jī)).
This works, however I need to make my application disable the alt + tab keyboard shortcut, as currently the user can use this to skip over my lock page (and thus be able to use the computer without having been authenticated).
任何建議將不勝感激.
推薦答案
您可以為窗口打開信息亭模式,使其全屏并始終在頂部,這樣您就無(wú)法轉(zhuǎn)到其他應(yīng)用程序.
You could turn on kiosk mode for the window which makes it full screen and always on top so you can't go to another application.
您還可以使窗口透明并將登錄信息放置在屏幕中間,這樣看起來(lái)就好像屏幕中間有一個(gè)窗口,但您不能點(diǎn)擊屏幕的其他區(qū)域.
You could also make the window transparent and position the login in the middle of the screen so it appears as if there is one window in the middle of the screen but you can't click on other areas of the screen.
要處理 Alt+F4 可以使用 window.onbeforeunload
事件或調(diào)用 event.preventDefault()
close
事件中的 code>.
To handle for Alt+F4 you can use the window.onbeforeunload
event or call event.preventDefault()
in the close
event.
https://electron.atom.io/docs/api/browser-window/#event-close
這篇關(guān)于在電子應(yīng)用程序中禁用鍵盤快捷鍵 Alt + Tab的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!