Keyboard shortcuts

Ctrl+K opens search, / focuses the box, ? shows help. Ignore shortcuts while typing in a field.

jQuery · Keyboard shortcutsAdvanced
$(document).on('keydown', function (e) {
  const typing = $(e.target).is('input, textarea, select, [contenteditable]');
  const mod = e.ctrlKey || e.metaKey;

  if (mod && e.key.toLowerCase() === 'k') {
    e.preventDefault();
    $('#search').focus();
  } else if (!typing && e.key === '/') {
    e.preventDefault();
    $('#search').focus();
  } else if (!typing && e.key === '?') {
    $('#help').toggle();
  } else if (e.key === 'Escape') {
    $('#help').hide();
    $('#search').blur();
  }
});
keyboardshortcutkeydownaccessibility