HTML कीबोर्ड शॉर्टकट्स
In this page:
स्टैंडर्ड Tab Key नेविगेशन
Webpages को Tab key से क्रम में navigate किया जा सकता है। आधुनिक browsers interactive elements (जैसे buttons, links, और inputs) को अपने आप tab sequence में natively शामिल कर लेते हैं।
उदाहरण: Standard Tab Key Navigation
<a href="/home">Home</a>
<button>Click me</button>
<input type="text">
accesskey से Custom Hotkeys
global accesskey attribute आपको specific elements के लिए custom keyboard shortcuts define करने देता है, जिससे users simple key combinations से actions trigger कर सकते हैं या input fields में focus रख सकते हैं।
- अपने primary navigation links के लिए आसान, याद रखने लायक letters को accesskey shortcuts के तौर पर असाइन करें।
- Accepted values:
- accesskey — one character or space-separated list of characters
- Activated with browser-specific modifier keys (e.g. Alt+key)
उदाहरण: Custom Hotkeys with accesskey
<a href="/home" accesskey="h">Home</a>
tabindex से Focus Management
global tabindex attribute आपको chronological keyboard tab sequence को मैन्युअल तरीके से control करने देता है। custom elements को sequence में शामिल करने के लिए tabindex="0" सेट करें, या उन्हें हटाने के लिए tabindex="-1"।
- सिर्फ tabindex="0" या tabindex="-1" इस्तेमाल करें; positive numbers इस्तेमाल करने से बचें क्योंकि ये logical tab navigation flow को बिगाड़ सकते हैं।
- Accepted values:
- 0 — focusable in DOM order
- 1 — focusable by script only, skipped by Tab
- positive integer — explicit tab order (avoid)
उदाहरण: Focus Management with tabindex
<div tabindex="0">Focusable custom element</div>
<div tabindex="-1">Not in tab order</div>
JavaScript में Custom Event Hotkeys
आप keypress events (जैसे Keydown या Keyup) सुनने और अपने page पर specific actions trigger करने के लिए custom JavaScript scripts लिख सकते हैं, जिससे आप rich, application-specific hotkey shortcuts बना सकते हैं।
उदाहरण: Custom Event Hotkeys in JavaScript
<input type="text" onkeydown="if (event.key === 'Enter') console.log('submitted')">
स्पष्ट Focus Indicators डिज़ाइन करना
keyboard users को यह देखने के लिए एक visible focus indicator चाहिए होता है कि navigate करते समय कौन-सा element currently selected है। आप इस indicator की style को customize करने और उसे साफ दिखाने के लिए CSS pseudo-classes इस्तेमाल कर सकते हैं।
उदाहरण: Designing Clear Focus Indicators
<style>
a:focus {
outline: 2px solid orange;
}
</style>
<a href="/home">Home</a>
Chapter Quiz — Complete all 20 topics to unlock
0/20 topics done
Complete these topics first:
- HTML Keyboard Shortcuts
- HTML Browser Support
- HTML Character Sets
- HTML Doctypes
- HTML Audio/Video Reference
- HTML Meta Tags
- HTML ARIA Roles
- HTML Input Validation
- HTML Iframe Security
- HTML Responsive Images
- HTML Web Fonts
- HTML Icon Fonts
- HTML Progress & Meter
- HTML Output Element
- HTML Datalist
- HTML Image Maps
- HTML Browser DevTools
- HTML Validation
- HTML Quiz
- HTML Interview Prep