Skip to content

Commit

Permalink
Use Mousetrap for shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Oct 28, 2018
1 parent ac65115 commit 11626bd
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 81 deletions.
25 changes: 13 additions & 12 deletions src/js/whatsapp.init.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { ipcRenderer } = require('electron');
const { Mousetrap } = require('mousetrap');

window.onclick = function(e) {
if (e.target.tagName == "A") {
Expand All @@ -7,15 +8,15 @@ window.onclick = function(e) {
}

/* Mac Copy/Paste Fix */
var isCtrl = false;
var isCmd = false;
window.onkeyup = function(e) {
if (e.which == 17) isCtrl = false;
if (e.which == 91) isCmd = false;
}
window.onkeydown = function(e) {
if (e.which == 17) isCtrl = true;
if (e.which == 91) isCmd = false;
if (e.which == 67 && (isCtrl || isCmd)) document.execCommand('copy');
if (e.which == 86 && (isCtrl || isCmd)) document.execCommand('paste');
}
Mousetrap.bind(['command+c', 'ctrl+c'], function(e) {
document.execCommand('copy');
});
Mousetrap.bind(['command+v', 'ctrl+v'], function(e) {
document.execCommand('paste');
});
Mousetrap.bind(['command+x', 'ctrl+x'], function(e) {
document.execCommand('cut');
});
Mousetrap.bind(['command+a', 'ctrl+a'], function(e) {
document.execCommand('selectAll');
});
142 changes: 73 additions & 69 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -1,76 +1,80 @@
{
"name": "altus",
"version": "1.2.1",
"description": "Electron-based desktop wrapper for Whatsapp Web",
"homepage": "https://github.com/ShadyThGod/altus",
"bugs": {
"url": "https://github.com/ShadyThGod/altus/issues"
"name": "altus",
"version": "1.2.1",
"description": "Electron-based desktop wrapper for Whatsapp Web",
"homepage": "https://github.com/ShadyThGod/altus",
"bugs": {
"url": "https://github.com/ShadyThGod/altus/issues"
},
"main": "main.js",
"scripts": {
"start": "electron ."
},
"build": {
"appId": "harwara.aman.altus",
"productName": "Altus",
"nsis": {
"oneClick": "false",
"artifactName": "${productName}-Setup-${version}.${ext}"
},
"main": "main.js",
"scripts": {
"start": "electron ."
},
"build": {
"appId": "harwara.aman.altus",
"productName": "Altus",
"nsis": {
"oneClick": "false",
"artifactName": "${productName}-Setup-${version}.${ext}"
},
"win": {
"target": [{
"target": "nsis",
"arch": [
"x64",
"ia32"
]
}],
"icon": "build/icon.ico"
},
"linux": {
"category": "Chat",
"target": [
"AppImage",
"deb"
]
},
"mac": {
"category": "public.app-category.social-networking",
"target": [
"dmg"
]
},
"dmg": {
"background": "build/background.png",
"icon": "build/icon.icns",
"iconSize": 100,
"contents": [{
"x": 380,
"y": 280,
"type": "link",
"path": "/Applications"
},
{
"x": 110,
"y": 280,
"type": "file"
}
],
"window": {
"width": 500,
"height": 400
}
"win": {
"target": [
{
"target": "nsis",
"arch": [
"x64",
"ia32"
]
}
],
"icon": "build/icon.ico"
},
"author": {
"name": "ShadyThGod",
"email": "[email protected]"
"linux": {
"category": "Chat",
"target": [
"AppImage",
"deb"
]
},
"license": "GNU GPLv3",
"devDependencies": {
"electron": "^2.0.8"
"mac": {
"category": "public.app-category.social-networking",
"target": [
"dmg"
]
},
"dependencies": {
"node-fetch": "^2.2.0"
"dmg": {
"background": "build/background.png",
"icon": "build/icon.icns",
"iconSize": 100,
"contents": [
{
"x": 380,
"y": 280,
"type": "link",
"path": "/Applications"
},
{
"x": 110,
"y": 280,
"type": "file"
}
],
"window": {
"width": 500,
"height": 400
}
}
}
},
"author": {
"name": "ShadyThGod",
"email": "[email protected]"
},
"license": "GNU GPLv3",
"devDependencies": {
"electron": "^2.0.8"
},
"dependencies": {
"mousetrap": "^1.6.2",
"node-fetch": "^2.2.0"
}
}

0 comments on commit 11626bd

Please sign in to comment.