Skip to content

Commit 161d25e

Browse files
authored
Allow for CMD+W or CTRL+W closing when in PWA mode (#6041)
Fixes #2089
1 parent 149a5d0 commit 161d25e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/app/src/app/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,19 @@ if (module.hot) {
231231
);
232232
});
233233
}
234+
235+
const isInStandaloneMode = () =>
236+
'standalone' in window.navigator && window.navigator.standalone;
237+
238+
// If we're in PWA mode we want to override CMD+W, so that people can use that to close the tabs. This is a little
239+
// hack, but gives good QoL improvement for a small effort.
240+
if (isInStandaloneMode()) {
241+
document.addEventListener('keydown', e => {
242+
if (
243+
(window.navigator.platform.match('Mac') ? e.metaKey : e.ctrlKey) &&
244+
e.keyCode === 83
245+
) {
246+
e.preventDefault();
247+
}
248+
});
249+
}

0 commit comments

Comments
 (0)