Skip to content

Commit f755520

Browse files
committed
fix: mac support for "control" key
1 parent 5c1d4e9 commit f755520

8 files changed

Lines changed: 22 additions & 9 deletions

File tree

src/base/chat/context.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ignoreUser from 'src/utils/ignoreUser.js';
99
import decode from 'src/utils/decode.js';
1010
import { buttonCSS, window } from 'src/utils/1.variables.js';
1111
import Translation from 'src/structures/constants/translation.ts';
12+
import isCtrl from 'src/utils/isCtrl';
1213

1314
const setting = settings.register({
1415
name: Translation.Setting('chat.rightclick'),
@@ -98,7 +99,7 @@ eventManager.on('jQuery', () => {
9899
mute.append(' ', muteTime);
99100

100101
function open(event) {
101-
if (event.ctrlKey || setting.value()) return;
102+
if (isCtrl(event) || setting.value()) return;
102103
if (toast) {
103104
toast.close('opened');
104105
}

src/base/library/craft/max.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import onPage from 'src/utils/onPage.js';
66
import * as hover from 'src/utils/hover.js';
77
import * as cardHelper from 'src/utils/cardHelper.js';
88
import Translation from 'src/structures/constants/translation.js';
9+
import isCtrl from 'src/utils/isCtrl.js';
910
import setBypass from './protection.js';
1011

1112
const setting = settings.register({
@@ -50,7 +51,7 @@ onPage('Crafting', function craftMax() {
5051
card.off('click').on('click.script', (e) => {
5152
const id = parseInt(card.attr('id'), 10);
5253
const shiny = card.hasClass('shiny');
53-
if (e.ctrlKey) {
54+
if (isCtrl(e)) {
5455
hover.hide();
5556
const count = max - cardHelper.quantity(el);
5657
if (count <= 0) return;

src/base/library/deck/random.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ eventManager.on(':preload:Decks', () => {
102102
clearDeck.after(' ', button);
103103
});
104104

105-
function getMode({ ctrlKey = false, shiftKey = false }) {
106-
if (ctrlKey) return true;
105+
function getMode({ ctrlKey = false, metaKey = false, shiftKey = false }) {
106+
if (ctrlKey || metaKey) return true;
107107
if (shiftKey) return false;
108108
return undefined;
109109
}

src/base/library/deck/storage.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { cardName } from 'src/utils/cardHelper.js';
1111
import { translateText } from 'src/utils/translate';
1212
import { getTranslationArray } from 'src/base/underscript/translation';
1313
import Translation from 'src/structures/constants/translation.ts';
14+
import isCtrl from 'src/utils/isCtrl';
1415

1516
// TODO: translation
1617
const setting = settings.register({
@@ -220,10 +221,11 @@ onPage('Decks', function deckStorage() {
220221
saveButton();
221222
return;
222223
}
223-
if (e.ctrlKey && e.shiftKey) { // Crazy people...
224+
const ctrlKey = isCtrl(e);
225+
if (ctrlKey && e.shiftKey) { // Crazy people...
224226
return;
225227
}
226-
if (e.ctrlKey) { // ERASE
228+
if (ctrlKey) { // ERASE
227229
localStorage.removeItem(nameKey);
228230
localStorage.removeItem(deckKey);
229231
refreshHover(); // Update

src/base/store/buyPacks.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import wrap from 'src/utils/2.pokemon.js';
55
import sleep from 'src/utils/sleep.js';
66
import * as api from 'src/utils/4.api.js';
77
import Translation from 'src/structures/constants/translation.ts';
8+
import isCtrl from 'src/utils/isCtrl.js';
89
import { getTranslationArray } from '../underscript/translation.js';
910

1011
wrap(() => {
@@ -39,7 +40,7 @@ wrap(() => {
3940
}
4041

4142
function getCount(e, cost, baseCost) {
42-
if (e.ctrlKey) return Math.floor(parseInt($(cost ? '#ucp' : '#golds').text(), 10) / baseCost);
43+
if (isCtrl(e)) return Math.floor(parseInt($(cost ? '#ucp' : '#golds').text(), 10) / baseCost);
4344
if (e.altKey) return 10;
4445
return 1;
4546
}

src/base/store/quickPacks.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { getCollection } from 'src/utils/user.js';
1111
import { buttonCSS as css, window } from 'src/utils/1.variables.js';
1212
import Item from 'src/structures/constants/item.js';
1313
import length from 'src/utils/length';
14+
import isCtrl from 'src/utils/isCtrl';
1415

1516
onPage('Packs', async function quickOpenPack() {
1617
const collection = await getCollection();
@@ -281,7 +282,7 @@ onPage('Packs', async function quickOpenPack() {
281282
});
282283
// TODO: translation
283284
$('[id^="btnOpen"]').on('click.script', (event) => {
284-
autoOpen = event.ctrlKey;
285+
autoOpen = isCtrl(event);
285286
const type = $(event.target).prop('id').substring(7);
286287
const count = autoOpen ? 1 : parseInt($(`#nb${type}Packs`).text(), 10);
287288
if (event.shiftKey) {

src/base/vanilla/pageShortcuts.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import * as settings from 'src/utils/settings/index.js';
33
import { global, globalSet } from 'src/utils/global.js';
44
import * as hover from 'src/utils/hover.js';
55
import Translation from 'src/structures/constants/translation.ts';
6+
import isCtrl from 'src/utils/isCtrl';
67

78
const disable = settings.register({
89
name: Translation.Setting('page.jump'),
910
key: 'underscript.disable.quickpages',
1011
});
1112

1213
function ignoring(e) {
13-
const ignore = disable.value() || !e.ctrlKey;
14+
const ignore = disable.value() || !isCtrl(e);
1415
if (ignore && [0, global('getMaxPage')()].includes(global('currentPage'))) hover.hide();
1516
return ignore;
1617
}

src/utils/isCtrl.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @param {KeyboardEvent} event
3+
*/
4+
export default function isCtrl(event) {
5+
return event.ctrlKey || event.metaKey;
6+
}

0 commit comments

Comments
 (0)