सुलभता पैटर्न · बटन और क्रियाएँ

कमांड पैलेट

पैलेट एक कॉम्बोबॉक्स के चारों ओर बना मोडल डायलॉग है: टाइप करने से समूहों वाला लिस्टबॉक्स छँटता है, और फ़ोकस फ़ील्ड में रहते हुए ऐरो कुंजियाँ हाइलाइट को आगे-पीछे करती हैं। aria-activedescendant स्क्रीन रीडर को बताता है कि कौन-सी कमांड हाइलाइट है, और टाइपिंग रुकते ही एक शांत स्टेटस बताता है कि कितनी कमांड मेल खाती हैं।

डब्ल्यूसीएजी मानदंड
7
कीबोर्ड नियम
7
जाँच का तरीक़ा
axe, कीबोर्ड और इंस्पेक्टर

लाइव डेमो

आज़माएँ

इसे माउस, कीबोर्ड या स्क्रीन रीडर से इस्तेमाल करें। साथ का इंस्पेक्टर दिखाता है कि आपके इस्तेमाल के दौरान ब्राउज़र सहायक तकनीक को क्या बताता है: फ़ोकस, स्थिति में बदलाव और घोषणाएँ।

नोटबुक

फ़ोकस इस डेमो में कहीं भी हो, शॉर्टकट काम करता है: Ctrl+K, या Mac पर ⌘+K।

अभी कोई कमांड नहीं चलाई गई

नया नोट
नोट डुप्लीकेट करें
पीडीएफ के रूप में एक्सपोर्ट करें
इनबॉक्स
कैलेंडर
सेटिंग्स
थीम बदलें
ज़ूम इन करें
कीबोर्ड शॉर्टकट

9 कमांड

जावास्क्रिप्ट के बिना डेमो उतना ही काम करता है जितना उसका एचटीएमएल; इंस्पेक्टर के लिए जावास्क्रिप्ट चाहिए।

कीबोर्ड

जिन कुंजियों पर यह काम करता है

हर क्रिया पॉइंटर के बिना काम करती है।

कुंजीयह क्या करती है
CtrlKया⌘Kफ़ोकस डेमो में कहीं भी हो, पैलेट खोलता है; पैलेट में दबाने पर खोज का टेक्स्ट चुनता है।
EnterयाSpaceकमांड खोजें पर, पैलेट खोलता है और फ़ोकस खोज फ़ील्ड में रखता है।
Arrow DownयाArrow Upहाइलाइट को अगली या पिछली मेल खाती कमांड पर ले जाता है, सिरों पर घूमकर दूसरी ओर पहुँचता है और समूहों के नाम छोड़ देता है।
A–Zटाइप करने से कमांड छँटती हैं; टाइपिंग रुकने पर मेल खाने वाली कमांड की संख्या घोषित होती है।
Ctrl,याCtrlShiftLयाCtrl/पैलेट बंद हो और फ़ोकस डेमो में हो, तो वह कमांड चलाता है जिसके संकेत में ये कुंजियाँ हैं (Mac पर Ctrl की जगह ⌘)।
Enterहाइलाइट वाली कमांड चलाता है, पैलेट बंद करता है और फ़ोकस वहीं लौटाता है जहाँ वह पहले था।
Escapeकुछ चलाए बिना पैलेट बंद करता है और फ़ोकस लौटाता है।

स्क्रीन रीडर

यह क्या घोषित करता है

मार्कअप की भूमिकाओं, नामों और स्थितियों से लिखा गया।

कबअपेक्षित घोषणा
फ़ोकस बटन पर पहुँचता हैकमांड खोजें, बटन, डायलॉग खोलता है, Control+K
पैलेट खुलता हैकमांड पैलेट, डायलॉग। कमांड खोजें, कॉम्बो बॉक्स, खुला। नया नोट, 9 में से 1
Arrow Down हाइलाइट आगे ले जाता हैनोट डुप्लीकेट करें, 9 में से 2
"cal" टाइप करने पर एक ही कमांड बचती है1 कमांड
कुछ भी मैच नहीं करताकोई कमांड मेल नहीं खाती
Enter कैलेंडर चलाता हैकमांड खोजें, बटन। चलाया गया: कैलेंडर

ये अपेक्षित घोषणाएँ हैं, रिकॉर्डिंग नहीं। स्क्रीन रीडर और ब्राउज़र के हिसाब से शब्द और क्रम बदलते हैं।

कोड

कोड कॉपी करें

वही फ़ाइलें जिन पर यह डेमो चलता है। स्टाइल एक प्रीफ़िक्स के साथ परोसी जाती हैं जो इस साइट की अपनी स्टाइल को डेमो से दूर रखता है; आप जो कॉपी करते हैं वह मूल है।

मार्कअप

<div class="ap-command-palette" data-ap-command-palette>
  <div class="ap-command-palette__app">
    <div class="ap-command-palette__bar">
      <p class="ap-command-palette__brand">
        <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M6 3h9l4 4v14H6Z"/><path d="M14 3v5h5"/><path d="M9 13h6M9 17h4"/></svg>
        <span>Notebook</span>
      </p>
      <button type="button" class="ap-command-palette__open" data-ap-open aria-haspopup="dialog" aria-keyshortcuts="Control+K Meta+K">
        <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
        <span class="ap-command-palette__open-text">Search commands</span>
        <span class="ap-command-palette__keys" aria-hidden="true"><kbd>Ctrl</kbd><kbd>K</kbd></span>
      </button>
    </div>
    <div class="ap-command-palette__page">
      <label class="ap-command-palette__note-label" for="command-palette-note">Quick note</label>
      <textarea class="ap-command-palette__note" id="command-palette-note" rows="3" placeholder="Write something, then press Ctrl+K without leaving the field."></textarea>
      <p class="ap-command-palette__hint">The shortcut works while focus is anywhere in this demo: <span class="ap-command-palette__combo"><kbd>Ctrl</kbd>+<kbd>K</kbd></span>, or <span class="ap-command-palette__combo"><kbd>⌘</kbd>+<kbd>K</kbd></span> on a Mac.</p>
    </div>
    <p class="ap-command-palette__status" role="status">No command run yet</p>
  </div>

  <dialog class="ap-command-palette__dialog" aria-label="Command palette">
    <div class="ap-command-palette__search">
      <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
      <input class="ap-command-palette__input" id="command-palette-input" type="text" role="combobox" aria-label="Search commands" aria-expanded="true" aria-controls="command-palette-list" aria-autocomplete="list" autocomplete="off" spellcheck="false" placeholder="Type a command or search" />
      <kbd class="ap-command-palette__esc" aria-hidden="true">Esc</kbd>
    </div>
    <div class="ap-command-palette__list" id="command-palette-list" role="listbox" aria-label="Commands">
      <div class="ap-command-palette__group" role="group" aria-labelledby="command-palette-g-notes">
        <div class="ap-command-palette__group-name" id="command-palette-g-notes" role="presentation">Notes</div>
        <div class="ap-command-palette__opt" role="option" id="command-palette-o-new" aria-selected="false" data-words="new note create add page">
          <svg class="ap-command-palette__ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 5v14M5 12h14"/></svg>
          <span class="ap-command-palette__name">New note</span>
        </div>
        <div class="ap-command-palette__opt" role="option" id="command-palette-o-duplicate" aria-selected="false" data-words="duplicate note copy clone">
          <svg class="ap-command-palette__ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V5a2 2 0 0 1 2-2h10"/></svg>
          <span class="ap-command-palette__name">Duplicate note</span>
        </div>
        <div class="ap-command-palette__opt" role="option" id="command-palette-o-export" aria-selected="false" data-words="export as pdf download save print">
          <svg class="ap-command-palette__ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 4v11"/><path d="m7 10 5 5 5-5"/><path d="M5 20h14"/></svg>
          <span class="ap-command-palette__name">Export as PDF</span>
        </div>
      </div>
      <div class="ap-command-palette__group" role="group" aria-labelledby="command-palette-g-go">
        <div class="ap-command-palette__group-name" id="command-palette-g-go" role="presentation">Go to</div>
        <div class="ap-command-palette__opt" role="option" id="command-palette-o-inbox" aria-selected="false" data-words="go to inbox messages mail">
          <svg class="ap-command-palette__ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M3 13h5l1.5 3h5l1.5-3h5"/><path d="M5.5 5h13L21 13v6H3v-6Z"/></svg>
          <span class="ap-command-palette__name">Inbox</span>
        </div>
        <div class="ap-command-palette__opt" role="option" id="command-palette-o-calendar" aria-selected="false" data-words="go to calendar schedule events dates">
          <svg class="ap-command-palette__ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="3.5" y="5" width="17" height="15" rx="2"/><path d="M3.5 10h17M8 3v4M16 3v4"/></svg>
          <span class="ap-command-palette__name">Calendar</span>
        </div>
        <div class="ap-command-palette__opt" role="option" id="command-palette-o-settings" aria-selected="false" aria-keyshortcuts="Control+, Meta+," data-words="go to settings preferences options account">
          <svg class="ap-command-palette__ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="3"/><path d="M12 2.5v3M12 18.5v3M4.2 6.5l2.6 1.5M17.2 16l2.6 1.5M4.2 17.5 6.8 16M17.2 8l2.6-1.5"/></svg>
          <span class="ap-command-palette__name">Settings</span>
          <span class="ap-command-palette__keys" aria-hidden="true"><kbd>Ctrl</kbd><kbd>,</kbd></span>
        </div>
      </div>
      <div class="ap-command-palette__group" role="group" aria-labelledby="command-palette-g-view">
        <div class="ap-command-palette__group-name" id="command-palette-g-view" role="presentation">Display</div>
        <div class="ap-command-palette__opt" role="option" id="command-palette-o-theme" aria-selected="false" aria-keyshortcuts="Control+Shift+L Meta+Shift+L" data-words="switch theme dark light mode appearance">
          <svg class="ap-command-palette__ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M20 14.5A8 8 0 1 1 9.5 4a6.5 6.5 0 0 0 10.5 10.5Z"/></svg>
          <span class="ap-command-palette__name">Switch theme</span>
          <span class="ap-command-palette__keys" aria-hidden="true"><kbd>Ctrl</kbd><kbd>Shift</kbd><kbd>L</kbd></span>
        </div>
        <div class="ap-command-palette__opt" role="option" id="command-palette-o-zoom" aria-selected="false" data-words="zoom in bigger larger text size">
          <svg class="ap-command-palette__ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5M11 8v6M8 11h6"/></svg>
          <span class="ap-command-palette__name">Zoom in</span>
        </div>
        <div class="ap-command-palette__opt" role="option" id="command-palette-o-keys" aria-selected="false" aria-keyshortcuts="Control+/ Meta+/" data-words="keyboard shortcuts keys hotkeys help">
          <svg class="ap-command-palette__ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="2.5" y="6" width="19" height="12" rx="2"/><path d="M6 10h.01M9.5 10h.01M13 10h.01M16.5 10h.01M7 14h10"/></svg>
          <span class="ap-command-palette__name">Keyboard shortcuts</span>
          <span class="ap-command-palette__keys" aria-hidden="true"><kbd>Ctrl</kbd><kbd>/</kbd></span>
        </div>
      </div>
    </div>
    <div class="ap-command-palette__empty" data-ap-no-match hidden>
      <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5M8.5 8.5l5 5M13.5 8.5l-5 5"/></svg>
      <p class="ap-command-palette__empty-lead">No commands match</p>
      <p class="ap-command-palette__empty-hint">Try a shorter word, or another name for what you want to do.</p>
    </div>
    <div class="ap-command-palette__foot">
      <p class="ap-command-palette__count"><span data-ap-n translate="no">9</span> <span data-ap-unit>commands</span></p>
      <p class="ap-command-palette__how" aria-hidden="true"><kbd>↑</kbd><kbd>↓</kbd> <span>to move</span> <kbd>↵</kbd> <span>to run</span></p>
    </div>
    <p class="ap-command-palette__say" role="status" data-ap-say></p>
  </dialog>
</div>

डब्ल्यूसीएजी 2.2

यह किन मानदंडों को पूरा करता है

वे सफलता मानदंड जिनका यह पैटर्न ध्यान रखता है, और कैसे।

  • 1.3.1 जानकारी और संबंध स्तर A

    कमांड लिस्टबॉक्स के अंदर नाम वाले समूहों में हैं, इसलिए स्क्रीन रीडर यहाँ जाएँ वाली कमांड को डिस्प्ले वाली कमांड से अलग बता पाता है।

  • 1.4.1 रंग का उपयोग स्तर A

    हाइलाइट वाली कमांड को भराव के साथ किनारे पर एक पट्टी भी मिलती है, इसलिए वह रंग पर निर्भर नहीं रहती।

  • 2.1.1 कीबोर्ड स्तर A

    शॉर्टकट के साथ एक दिखने वाला बटन भी पैलेट खोलता है, और हर कमांड ऐरो कुंजियों और Enter से चलती है।

  • 2.1.4 कैरेक्टर-की शॉर्टकट स्तर A

    शॉर्टकट के लिए Ctrl या ⌘ चाहिए, इसलिए वह किसी के टाइप या डिक्टेट करते समय नहीं चल सकता, और वह सिर्फ़ डेमो के अंदर सुनता है।

  • 2.4.3 फ़ोकस क्रम स्तर A

    पैलेट खुलने पर फ़ोकस खोज फ़ील्ड में जाता है और बंद होने पर उस बटन या फ़ील्ड पर लौटता है जिसने उसे खोला था।

  • 4.1.2 नाम, भूमिका, मान स्तर A

    फ़ील्ड aria-expanded और aria-controls वाला कॉम्बोबॉक्स है; aria-activedescendant हाइलाइट वाले विकल्प की ओर इशारा करता है, जिस पर aria-selected होता है।

  • 4.1.3 स्टेटस मैसेज स्तर AA

    टाइपिंग रुकने पर मेल खाने वाली कमांड की संख्या एक शांत स्टेटस से घोषित होती है, फ़ोकस हिलाए बिना।

उपयोग

इसे कब इस्तेमाल करें

इसे अपनाएँ

  • ऐसे ऐप जिनमें मेन्यू और टूलबार में समाने से ज़्यादा कमांड हैं, उन लोगों के लिए जो ढूँढने की बजाय टाइप करना पसंद करते हैं।
  • उन एक्शन तक जल्दी पहुँचने का रास्ता जो इंटरफ़ेस में कहीं दिखते भी हैं।

कुछ और इस्तेमाल करें

  • किसी कमांड के अकेले ठिकाने के रूप में: जो लोग कभी Ctrl+K नहीं दबाते, उन्हें वह इंटरफ़ेस में मिलनी चाहिए।
  • साइट की सामग्री खोजना: नतीजों के पेज वाला खोज फ़ील्ड समझने और बुकमार्क करने में आसान है।
  • गिने-चुने एक्शन: मेन्यू बटन या टूलबार उन्हें बिना टाइप किए दिखा देता है।

आम विफलताएँ

आमतौर पर यह कहाँ गलत होता है

  • हर जगह सुनने वाला शॉर्टकट

    पूरे डॉक्यूमेंट पर Ctrl+K पेज के एडिटर और दूसरे विजेट से वह कुंजी छीन लेता है। यहाँ लिसनर डेमो पर है, इसलिए वह सिर्फ़ उसके अंदर जवाब देता है।

  • फ़ोकस को सूची में ले जाना

    अगर ऐरो कुंजियाँ असली फ़ोकस को विकल्पों पर ले जाएँ, तो फ़ील्ड पर लौटने तक टाइपिंग रुक जाती है। aria-activedescendant सिर्फ़ हाइलाइट को हिलाता है।

  • नतीजे जो कोई सुनता नहीं

    देख सकने वाले लोग सूची छोटी होते देखते हैं; गिनती घोषित न हो तो स्क्रीन रीडर इस्तेमाल करने वाले कुछ नहीं सुनते। टाइपिंग रुकने पर एक शांत स्टेटस यह बताता है।

  • हर कुंजी पर घोषणा

    हर अक्षर पर लाइव रीजन बदलने से स्क्रीन रीडर टाइपिंग के ऊपर बोलता रहता है। गिनती थोड़े ठहराव का इंतज़ार करती है।

  • डायलॉग की जगह तैरता बॉक्स

    पोज़िशन किया गया div पीछे के पेज को Tab और वर्चुअल कर्सर के लिए खुला छोड़ देता है। showModal() पैलेट खुला रहने तक बाकी पेज को निष्क्रिय कर देता है।

  • कुछ न करने वाले शॉर्टकट संकेत

    किसी कमांड के पास दिखा संकेत यह वादा है कि कुंजियाँ काम करेंगी। यहाँ हर संकेत अपनी कमांड चलाता है, और aria-keyshortcuts वही कुंजियाँ सहायक तकनीक को बताता है।

नोट्स

इसे बनाना

  • सिर्फ़ शॉर्टकट वाली कमांड संकेत दिखाती हैं, और हर संकेत सच में जुड़ा है: दिखने वाली कुंजियाँ aria-hidden हैं क्योंकि aria-keyshortcuts उन्हें पहले ही बताता है।
  • मिलान लेबल और हर कमांड के कुछ छिपे कीवर्ड (data-words) से होता है, इसलिए "dark" टाइप करने पर थीम बदलें मिल जाता है।
  • समूहों के नाम role=presentation वाले एलिमेंट हैं जिनकी ओर हर समूह का aria-labelledby इशारा करता है, जैसा WAI-एआरआईए ऑथरिंग प्रैक्टिसेज़ के समूहों वाले लिस्टबॉक्स उदाहरण में है।
  • जब कुछ मेल नहीं खाता, लिस्टबॉक्स छिप जाता है, कॉम्बोबॉक्स aria-expanded=false बताता है, और एक ख़ाली स्थिति बताती है कि आगे क्या आज़माएँ।
  • Ctrl+K संभाल लेने के बाद डेमो उसे पेज तक नहीं जाने देता, ताकि उन्हीं कुंजियों वाली साइट की खोज भी साथ में न खुले।

स्रोत: WAI-एआरआईए ऑथरिंग प्रैक्टिसेज़: कॉम्बोबॉक्स · WAI-एआरआईए ऑथरिंग प्रैक्टिसेज़: लिस्टबॉक्स · एचटीएमएल: dialog एलिमेंट

लाइट और डार्क थीम में, डेस्कटॉप और फ़ोन की चौड़ाई पर axe से और कीबोर्ड से जाँचा गया। अभी हर स्क्रीन रीडर और ब्राउज़र जोड़ी के साथ नहीं परखा गया। सुधार बताएँ