'use strict'; // Desktop keyboard shortcuts for Mail (the video and music players have their own, in video.js and player.js), and "?" for the list of all of them. addEventListener('keydown', e => { if (e.metaKey || e.ctrlKey || e.altKey || document.getElementById('sheet') || document.body.classList.contains('editing')) return; const t = e.target, tag = t.tagName || '', k = e.key; if (/^(INPUT|TEXTAREA|SELECT)$/.test(tag) || t.isContentEditable) return; if (k === '?') { e.preventDefault(); return keysHelp(); } if (!location.hash.startsWith('#/mail') || typeof mail === 'undefined') return; if (k === 'j' || k === 'k') { // next / previous message in the list const rows = [...document.querySelectorAll('a.mrow')]; if (!rows.length) return; const sel = rows.findIndex(a => a.classList.contains('sel')), i = Math.max(0, Math.min(rows.length - 1, sel < 0 ? 0 : sel + (k === 'j' ? 1 : -1))); e.preventDefault(); location.hash = rows[i].getAttribute('href'); rows[i].scrollIntoView({ block: 'nearest' }); return; } if (!mail.msg) return; const act = { e: 'archive', '#': 'delete', Delete: 'delete', r: 'reply', a: 'replyAll', f: 'forward', u: 'unread', s: 'flag' }[k]; if (act) { e.preventDefault(); mailAction(act); } else if (k === 'Escape' || k === 'x') { location.hash = '#/mail/f/' + encodeURIComponent(mail.folder); } }); function keysHelp() { const row = (k, d) => `${k}${d}`; const el = openSheet('Keyboard shortcuts', '', `${row('Ctrl/⌘ K', 'Search and commands')}${row('?', 'This list')}${row('Space', 'Play or pause music')}${row('← →', 'Back or forward 10 s')}${row('N / P', 'Next or previous track')} ${row('J / K', 'Next or previous message')}${row('E', 'Archive')}${row('# or Delete', 'Delete')}${row('R / A / F', 'Reply, reply all, forward')}${row('U', 'Mark unread')}${row('S', 'Flag')}${row('Esc or X', 'Back to the list')} ${row('Space or K', 'Play or pause')}${row('← → / J L', 'Back or forward 10 s (30 s with Shift or J/L)')}${row('↑ ↓', 'Volume')}${row('F', 'Full screen')}${row('M', 'Mute')}${row('N / P', 'Next or previous episode')}${row('0–9', 'Jump to 0–90% of the way through')}
Anywhere
Mail
Video player
`); el.querySelector('#kx').onclick = closeSheet; }