久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Atom-shell 中禁用退格鍵

Disable backspace in Atom-shell(在 Atom-shell 中禁用退格鍵)
本文介紹了在 Atom-shell 中禁用退格鍵的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我一直在搜索 interwebz 和 Atom-shell 文檔,試圖找出如何在瀏覽器窗口中禁用 backspace 鍵的 back() 功能.

I've been scouring the interwebz and Atom-shell documentation trying to find out how to disable the back() functionality of the backspace key within a browser window.

我寧愿不必求助于 javascript onkeydown 偵聽器(它可以工作),而是使用更原生的東西,在更多的應用程序級別而不是瀏覽器窗口級別.

I would prefer not to have to resort to a javascript onkeydown listener (which works) and rather use something more native and at more of the application level instead of the browser window level.

推薦答案

我想出在沒有 onkeydown 監聽器的情況下做到這一點的唯一方法是使用全局快捷方式和 ipc 事件電子接口.

The only way I have figured out to do this without the onkeydown listener is with a global-shortcut and the ipc events in the Electron api.

首先聲明...

使用全局快捷方式禁用任何鍵確實會在您的計算機上全局禁用它!使用全球快捷方式時請小心!如果您忘記取消注冊您的快捷方式,或者沒有正確處理它,您會發現如果沒有退格,您將很難修復您的錯誤!

Disabling any key with a global shortcut really does disable it GLOBALLY on your computer! PLEASE BE CAREFUL WHEN USING GLOBAL SHORTCUTS! If you forget to unregister your shortcut, or do not handle it properly, you will find it difficult to fix your mistake without backspace!

也就是說這對我有用...

That said this is what worked for me...

const { app, ipcMain,
    globalShortcut,
    BrowserWindow,
} = require('electron');

app.on('ready', () => {

    // Create the browser window
    let mainWindow = new BrowserWindow({width: 800, height: 600});

    // and load the index.html of the app
    mainWindow.loadUrl('file://' + __dirname + '/index.html');

    // Register a 'Backspace' shortcut listener when focused on window
    mainWindow.on('focus', () => {

        if (mainWindow.isFocused()) {
            globalShortcut.register('Backspace', () => {

                // Provide feedback or logging here 
                // If you leave this section blank, you will get no
                // response when you try the shortcut (i.e. Backspace).

                console.log('Backspace was pressed!'); //comment-out or delete when ready.
            });
        });
    });

    //  ** THE IMPORTANT PART **
    // Unregister a 'Backspace' shortcut listener when leaving window.
    mainWindow.on('blur', () => {

        globalShortcut.unregister('Backspace');
        console.log('Backspace is unregistered!'); //comment-out or delete when ready.
    });
});

或者,您可以像這樣在 ipcToggle"事件處理程序中添加快捷方式...

Alternatively you could add the shortcut inside an ipc "Toggle" event handler like this...

// In the main process
ipcMain.on('disableKey-toggle', (event, keyToDisable) => {
    if (!globalShortcut.isRegistered(keyToDisable){

        globalShortcut.register(keyToDisable, () => {
            console.log(keyToDisable+' is registered!'); //comment-out or delete when ready.

        });
    } else {

        globalShortcut.unregister(keyToDisable);
        console.log(keyToDisable+' is unregistered!'); //comment-out or delete when ready.
    }
});

// In the render process send the accelerator of the keyToDisable.
// Here we use the 'Backspace' accelerator.
const { ipcRenderer } = require('electron');
ipcRenderer.send('disableKey-toggle', 'Backspace'); 

這篇關于在 Atom-shell 中禁用退格鍵的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 日韩精品一区二区三区在线观看 | 日韩无 | 激情久久网 | 九九综合 | 欧美日韩一区二区在线 | 国产一区二区三区视频免费观看 | 精品91久久久 | 精品一区二区三区在线观看国产 | 久久午夜视频 | 97av视频在线观看 | 日韩一级免费大片 | 欧美一区成人 | 夜夜草 | 久久久久午夜 | 国产亚洲区 | 免费h在线 | 欧美一区二区三区四区视频 | 国产成人精品亚洲日本在线观看 | 一区二区三区欧美 | 黄色三级在线播放 | 国产一级片91 | 中文字幕免费视频 | 91视频大全 | 99re国产视频 | 久久久免费在线观看 | 欧美激情欧美激情在线五月 | 亚洲欧美视频在线观看 | 看片91 | 日韩久久久久 | 中文字幕成人av | 欧美综合视频 | 国产女人与拘做受视频 | 天天色影视综合 | 视频在线一区二区 | 午夜在线视频 | 国产一区| 超碰伊人久久 | 99久久婷婷国产精品综合 | 欧美一区二区三区在线观看视频 | 在线观看日本高清二区 | 人和拘一级毛片c |