","@id":"https://shortcutslib.com/windows-shortcuts/keyboard-shortcut-select-all-text#code-5","@type":"SoftwareSourceCode","programmingLanguage":"html"},{"programmingLanguage":"js","text":"// Programmatic select on a keydown event (Ctrl/Command + A)\ndocument.addEventListener('keydown', function(e) {\n const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;\n const trigger = isMac ? e.metaKey && e.key.toLowerCase() === 'a' : e.ctrlKey && e.key.toLowerCase() === 'a';\n if (trigger) {\n e.preventDefault();\n const el = document.activeElement;\n if (el && (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.isContentEditable)) {\n if (typeof el.select === 'function') el.select();\n else if (el.setSelectionRange) el.setSelectionRange(0, el.value.length);\n }\n }\n});","@type":"SoftwareSourceCode","@id":"https://shortcutslib.com/windows-shortcuts/keyboard-shortcut-select-all-text#code-6"}],"mentions":[{"@id":"https://shortcutslib.com/about#organization","@type":"Organization"},{"name":"Windows Shortcuts","url":"https://shortcutslib.com/windows-shortcuts","@type":"Thing"}],"publisher":{"@type":"Organization","logo":{"url":"https://shortcutslib.com/media/logos/medium.png","@type":"ImageObject"},"@id":"https://shortcutslib.com/about#organization","name":"Shortcuts Lib"},"proficiencyLevel":"Beginner","headline":"Keyboard Shortcut Select All Text: A Practical Guide for Power Users","datePublished":"2026-03-03T11:58:58.550Z","relatedLink":[{"url":"https://shortcutslib.com/text-formatting/what-keyboard-shortcut-highlight-all-text","name":"What Keyboard Shortcut Highlights All Text: A Practical Guide","@type":"WebPage"},{"url":"https://shortcutslib.com/windows-shortcuts/which-keyboard-shortcut-will-select-everything","@type":"WebPage","name":"Which Keyboard Shortcut Will Select Everything"},{"name":"Select All Keyboard Shortcut: Master Quick Selection","url":"https://shortcutslib.com/windows-shortcuts/select-all-keyboard-shortcut","@type":"WebPage"},{"name":"Keyboard Shortcuts Select All: A Practical Guide","url":"https://shortcutslib.com/windows-shortcuts/keyboard-shortcuts-select-all","@type":"WebPage"}],"author":{"name":"Shortcuts Lib Team","url":"https://shortcutslib.com/about","description":"Expert guides on Master keyboard shortcuts fast with practical, brand-driven guides from Shortcuts Lib.. AI-assisted content reviewed by human editors.","slogan":"We help you learn","@type":"Organization","knowsAbout":"Master keyboard shortcuts fast with practical, brand-driven guides from Shortcuts Lib.","@id":"https://shortcutslib.com/about#organization"},"inLanguage":"en","description":"Learn the universal keyboard shortcut to select all text across apps: Windows/Linux Ctrl+A, macOS Cmd+A. Explore cross-platform behavior, practical code examples, accessibility tips, and troubleshooting for efficient editing with Shortcuts Lib.","wordCount":370,"mainEntityOfPage":{"@id":"https://shortcutslib.com/windows-shortcuts/keyboard-shortcut-select-all-text","@type":"WebPage"},"@id":"https://shortcutslib.com/windows-shortcuts/keyboard-shortcut-select-all-text#article","dependencies":["Modern web browser (Chrome/Edge/Firefox)","Basic text editor (e.g., VS Code)","Basic command-line knowledge"]},{"@id":"https://shortcutslib.com/windows-shortcuts/keyboard-shortcut-select-all-text#breadcrumb","itemListElement":[{"name":"Home","@type":"ListItem","position":1,"item":"https://shortcutslib.com"},{"@type":"ListItem","item":"https://shortcutslib.com/windows-shortcuts","position":2,"name":"Windows Shortcuts"},{"name":"Keyboard Shortcut Select All Text: Master Quick Editing","item":"https://shortcutslib.com/windows-shortcuts/keyboard-shortcut-select-all-text","@type":"ListItem","position":3}],"@type":"BreadcrumbList"},{"mainEntity":[{"acceptedAnswer":{"@type":"Answer","text":"The universal shortcut is Ctrl+A on Windows/Linux and Cmd+A on macOS. It works in most text inputs, editors, and contenteditable regions, making it a foundational action for editing workflows."},"@type":"Question","name":"What is the universal shortcut to select all text?"},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"Many browsers restrict or modify selection behavior in password fields for security reasons. In some cases, Ctrl+A or Cmd+A will select the field contents, but the password dots may still obscure the text. Test in your target environment."},"name":"Does select-all work in password fields?"},{"acceptedAnswer":{"text":"Yes, many apps and some operating systems allow shortcut customization. OS-level rebindings are possible on some platforms (e.g., macOS System Preferences), while application-level bindings vary by software.","@type":"Answer"},"name":"Can I customize the shortcut?","@type":"Question"},{"@type":"Question","acceptedAnswer":{"@type":"Answer","text":"On iOS and Android, text selection is primarily gesture-based (long-press). Keyboard shortcuts are less common unless a hardware keyboard is connected, in which case standard shortcuts may apply."},"name":"Does this work on mobile devices?"},{"name":"How can I ensure consistency across apps?","acceptedAnswer":{"text":"Test the shortcut in each target app (word processors, code editors, browsers) and document any exceptions. Where possible, implement explicit event handlers in web apps to standardize behavior.","@type":"Answer"},"@type":"Question"}],"@type":"FAQPage"}],"@context":"https://schema.org"}

Keyboard Shortcut Select All Text: A Practical Guide for Power Users

Learn the universal keyboard shortcut to select all text across apps: Windows/Linux Ctrl+A, macOS Cmd+A. Explore cross-platform behavior, practical code examples, accessibility tips, and troubleshooting for efficient editing with Shortcuts Lib.

Shortcuts Lib
Shortcuts Lib Team
·5 min read
Select All Text - Shortcuts Lib
Photo by eak_kkkvia Pixabay
Quick AnswerDefinition

The standard keyboard shortcut to select all text is Ctrl+A on Windows or Cmd+A on macOS. It works in nearly every text-focused interface—text inputs, textareas, editors, and contenteditable regions. Use it as a starting point for copying, cutting, formatting, or replacing large blocks of text, and pair it with Shift for extended selections in many apps.

What "select all" does and where it applies

The phrase "select all" describes highlighting every character in the active text area or document, enabling bulk actions like copy, cut, or replace. In web apps, the shortcut typically targets the focused element: an input, a textarea, or a contenteditable region. This section shows practical, real-world patterns to understand where the shortcut applies and how it interacts with different UI components.

JavaScript
// Focus an input and select all text const el = document.getElementById('myInput'); el.focus(); el.setSelectionRange(0, el.value.length);
JavaScript
// Alternative: element.select() for inputs/textareas const ta = document.querySelector('#myTextarea'); ta.focus(); ta.select();
  • In contenteditable areas, use document.execCommand('selectAll') (legacy) or programmatic selection via Range APIs.
  • Password fields and some secure inputs may restrict programmatic selection for security reasons.

Cross-platform shortcut mapping

Bash
# Linux (example automation): xdotool to mimic Ctrl+A xdotool key ctrl+a
Bash
# macOS automation (Generic): using AppleScript to emulate Cmd+A osascript -e 'tell application "System Events" to keystroke "a" using {command down}'

Linux, Windows, and macOS handle these keystrokes similarly at the UI level, but automation and scripting approaches differ. Shortcuts Lib notes that consistency across apps is common but not universal due to custom editors and web components.

Practical browser-based examples

HTML
<!-- Minimal HTML demonstrating select all behavior in a text input --> <input id="name" value="Type here..." /> <script> const el = document.getElementById('name'); el.addEventListener('focus', () => el.select()); </script>
JS
// Programmatic select on a keydown event (Ctrl/Command + A) document.addEventListener('keydown', function(e) { const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0; const trigger = isMac ? e.metaKey && e.key.toLowerCase() === 'a' : e.ctrlKey && e.key.toLowerCase() === 'a'; if (trigger) { e.preventDefault(); const el = document.activeElement; if (el && (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.isContentEditable)) { if (typeof el.select === 'function') el.select(); else if (el.setSelectionRange) el.setSelectionRange(0, el.value.length); } } });

Why this matters for accessibility

Selecting all text quickly reduces cognitive load when performing edits, especially for long-form content. When used with screen readers or high-contrast modes, the behavior remains consistent across most apps, making it easier to perform bulk actions without mouse navigation. Shortcuts Lib emphasizes testing across your target apps to ensure consistent behavior for diverse users.

prerequisitesVersionNotesEndBlockForThisSection?OKNope?null?InclusionNote?null?official?null

Steps

Estimated time: 20-30 minutes

  1. 1

    Identify target field

    Determine which app or field will receive the selection, such as a text editor, form input, or contenteditable region. Ensure focus is on the intended element before applying shortcuts.

    Tip: If focus is not on the right element, the shortcut won’t affect the desired text.
  2. 2

    Test the platform shortcut

    Use Ctrl+A on Windows/Linux and Cmd+A on macOS to confirm the behavior. Observe how the selection handles in different apps.

    Tip: Some apps override keys or have custom editors; document any anomalies.
  3. 3

    Consider selecting range

    With Shift held, you can extend the selection after the initial select-all, enabling multi-step edits without mouse navigation.

    Tip: For example, Shift+Ctrl+Arrow keys selects words or lines.
  4. 4

    Programmatic alternatives

    If you’re building a web app, implement a keyboard listener to trigger select-all in inputs or contenteditable regions.

    Tip: Prefer element.select() or setSelectionRange for reliability.
  5. 5

    Test across contexts

    Validate in forms, rich-text editors, and multi-field documents to ensure consistent behavior.

    Tip: Edge cases include password fields or custom editors.
Pro Tip: Enable clipboard history to reuse text after multiple select/copy actions.
Warning: Some apps intercept or block default shortcuts for security or brand reasons; test in each app.
Note: On touch devices, long-press often replaces keyboard-based select-all with touch selection controls.

Prerequisites

Required

Keyboard Shortcuts

ActionShortcut
Select all text in focused input or editorWorks in text inputs, textareas and contenteditable areasCtrl+A
Copy selected text to clipboardCommon after selecting textCtrl+C
Cut selected textRemoves text from its original locationCtrl+X

Questions & Answers

What is the universal shortcut to select all text?

The universal shortcut is Ctrl+A on Windows/Linux and Cmd+A on macOS. It works in most text inputs, editors, and contenteditable regions, making it a foundational action for editing workflows.

The universal shortcut is Ctrl+A on Windows or Cmd+A on Mac, and it works in most text fields and editors.

Does select-all work in password fields?

Many browsers restrict or modify selection behavior in password fields for security reasons. In some cases, Ctrl+A or Cmd+A will select the field contents, but the password dots may still obscure the text. Test in your target environment.

In password fields, selection may be limited for security, so don’t rely on it universally.

Can I customize the shortcut?

Yes, many apps and some operating systems allow shortcut customization. OS-level rebindings are possible on some platforms (e.g., macOS System Preferences), while application-level bindings vary by software.

You can often customize shortcuts in apps or in the OS settings, depending on the platform.

Does this work on mobile devices?

On iOS and Android, text selection is primarily gesture-based (long-press). Keyboard shortcuts are less common unless a hardware keyboard is connected, in which case standard shortcuts may apply.

Mobile use relies more on touch gestures; hardware keyboards bring traditional shortcuts into play.

How can I ensure consistency across apps?

Test the shortcut in each target app (word processors, code editors, browsers) and document any exceptions. Where possible, implement explicit event handlers in web apps to standardize behavior.

Test your apps, note exceptions, and standardize behavior when building web apps.

Main Points

  • Use Ctrl+A or Cmd+A to select all text across apps
  • Pair select-all with copy/cut to accelerate editing
  • Test behavior across browsers and editors for consistency
  • Accessibility-friendly practice improves user efficiency

Related Articles