generated from electron/electron-quick-start
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.js
54 lines (48 loc) · 1.42 KB
/
renderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* This file is loaded via the <script> tag in the index.html file and will
* be executed in the renderer process for that window. No Node.js APIs are
* available in this process because `nodeIntegration` is turned off and
* `contextIsolation` is turned on. Use the contextBridge API in `preload.js`
* to expose Node.js functionality from the main process.
*/
//var Mousetrap = require('mousetrap');
document.addEventListener('keyup', (e) => {
console.log("key: " + e.code);
//alert("老兄, 你敲了 " + e.code);
});
console.log("加载完成" + Date.now());
Mousetrap.bind('command+shift+k', function() { console.log('command shift k'); });
// Mousetrap.bind(['f11'], function() {
// console.log('f11');
//
// // return false to prevent default browser behavior
// // and stop event from bubbling
// return false;
// });
Mousetrap.bind(['ctrl+c', 'command+c'], function(e) {
if (e.preventDefault) {
e.preventDefault();
} else {
// internet explorer
e.returnValue = false;
}
console.log("forbid copy");
});
Mousetrap.bind(['ctrl+c', 'command+r'], function(e) {
if (e.preventDefault) {
e.preventDefault();
} else {
// internet explorer
e.returnValue = false;
}
console.log("forbid refresh");
});
Mousetrap.bind(['F11'], function(e) {
if (e.preventDefault) {
e.preventDefault();
} else {
// internet explorer
e.returnValue = false;
}
console.log("forbid F11");
});