mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 08:02:54 +11:00
Use CTRL+Enter on Linux (#121)
Currently, there's only "Windows and "not Windows", which makes all non-Windows platforms behave like Mac (i.e., they have a meta key.). That's unfortunately not very true. Instead, I'd suggest use the apple meta key on platforms that are known to be Mac and support CTRL+Enter on all other platforms (Linux, Unix, etc.)
This commit is contained in:
parent
8825ef0930
commit
a19e6f26e1
1 changed files with 4 additions and 4 deletions
|
@ -3,8 +3,8 @@
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Add data-platform to the body tag to show platform related shortcuts
|
// Add data-platform to the body tag to show platform related shortcuts
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
const isWindows = navigator.appVersion.indexOf('Win') !== -1;
|
const isMac = navigator.platform.indexOf('Mac') !== -1;
|
||||||
document.body.dataset.platform = isWindows ? 'win' : 'mac';
|
document.body.dataset.platform = isMac ? 'mac' : 'win';
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Autofocus the content field on the homepage
|
// Autofocus the content field on the homepage
|
||||||
|
@ -18,7 +18,7 @@ if (af !== null) {
|
||||||
// Cmd+Enter or Ctrl+Enter submits the form
|
// Cmd+Enter or Ctrl+Enter submits the form
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
document.body.onkeydown = function(e) {
|
document.body.onkeydown = function(e) {
|
||||||
const metaKey = isWindows ? e.ctrlKey : e.metaKey;
|
const metaKey = isMac ? e.metaKey : e.ctrlKey;
|
||||||
const form = document.querySelector('.snippet-form');
|
const form = document.querySelector('.snippet-form');
|
||||||
|
|
||||||
if (form && e.keyCode === 13 && metaKey) {
|
if (form && e.keyCode === 13 && metaKey) {
|
||||||
|
|
Loading…
Reference in a new issue