'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) => `
| Anywhere | |
|---|---|
| Video player |