Added complete documentation for all TestDrive-JSUI controls and features, plus flexible HTML generation system supporting standalone and external modes. Documentation (8 files, 3,533 lines): - docs/features/README.md: Central hub with overview, config, examples - docs/features/section-editing.md: Section editing guide - docs/features/edit-control.md: Document actions and editing tools - docs/features/status-control.md: Real-time statistics and tracking - docs/features/contents-control.md: Table of contents navigation - docs/features/debug-control.md: Development and debugging tools - docs/features/keyboard-shortcuts.md: Complete shortcuts reference - docs/features/themes.md: Visual theming and customization HTML Generation System (3 files, 1,104 lines): - js/utils/html-generator.js: Dual-mode HTML generator class * Standalone mode: All CSS/JS embedded inline * External mode: References _jsui/ directory * Configurable options for title, content, controls, theme * Download and save functionality - _jsui/ directory: External resources structure * README.md: Comprehensive usage guide * css/: Symlinked CSS files (base, editor, controls, themes) * js/: Symlinked JavaScript files (core, components, controls) * Enables smaller HTML files with browser caching - examples/html-generator-demo.html: Interactive demo * Web-based configuration form * Side-by-side mode comparison * Live generation and preview * Download and copy functionality Key Features: - 4,637 total lines of documentation and code - All controls documented with examples and troubleshooting - Flexible deployment options (standalone vs external) - Developer-friendly structure with clear guides - Production-ready system 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
15 KiB
Keyboard Shortcuts
Quick actions via keyboard ⌨️
TestDrive-JSUI provides comprehensive keyboard shortcuts for efficient document editing and navigation. All shortcuts are enabled by default and work across all browsers. Keyboard shortcuts improve accessibility and productivity for power users.
Overview
Keyboard shortcuts provide fast access to common actions without reaching for the mouse. They're organized by context: global shortcuts, section editing shortcuts, and control-specific shortcuts.
Quick Reference
| Shortcut | Action | Context |
|---|---|---|
Ctrl+S |
Save document | Global |
Escape |
Close editor/dialog | Global |
Ctrl+Enter |
Accept changes | Section editing |
Ctrl+P |
Print document | Document (planned) |
Ctrl+F |
Find & replace | Document (planned) |
Ctrl+B |
Bold text | Text editing (planned) |
Ctrl+I |
Italic text | Text editing (planned) |
Tab |
Indent | Section editing |
Note: On macOS, Ctrl can be replaced with Cmd (⌘) for most shortcuts.
Configuration
Enable/Disable Shortcuts
Keyboard shortcuts are enabled by default. To disable:
new TestDriveJSUI({
container: '#editor',
shortcuts: false // Disable all keyboard shortcuts
});
When to disable:
- Conflict with existing application shortcuts
- Custom keyboard handling required
- Accessibility requirement for specific workflow
Check Shortcut Status
const editor = new TestDriveJSUI({ container: '#editor' });
console.log(editor.config.shortcuts); // true or false
Global Shortcuts
Available throughout the application, regardless of focus.
Ctrl+S (Save Document)
Action: Save/download current document as markdown file
Platforms:
- Windows/Linux:
Ctrl+S - macOS:
Cmd+S(⌘S)
Behavior:
- Prevents browser's default save behavior
- Calls
editor.save()method - Downloads file with timestamped name:
document-edited-YYYY-MM-DD-HHMMSS.md - Triggers
saveevent for custom handlers
Example:
const editor = new TestDriveJSUI({ container: '#editor' });
// Listen to save event
editor.on('save', (data) => {
console.log('Document saved via Ctrl+S');
console.log('Content:', data.markdown);
});
// User presses Ctrl+S → save event fires
Use cases:
- Quick save during writing
- Prevent accidental data loss
- Trigger auto-upload to server
Escape (Close Editor/Dialog)
Action: Close active floating editor or dialog
Platforms: All (no modifier key needed)
Behavior:
- Checks for active floating menu
- Closes section editor if open
- Cancels current edit operation
- Returns focus to document
Contexts:
- Section editing: Cancels edit, discards changes
- Find & replace: Closes find dialog (planned)
- Go to line: Closes navigation dialog (planned)
- Image editor: Closes image editor (planned)
Example:
// User clicks section to edit
// Section editor opens with textarea
// User presses Escape
// → Editor closes, changes discarded
Use cases:
- Quick cancel during editing
- Close dialogs without mouse
- Keyboard-only workflow
Section Editing Shortcuts
Active when editing a section (textarea has focus).
Ctrl+Enter (Accept Changes)
Action: Accept changes and close section editor
Platforms:
- Windows/Linux:
Ctrl+Enter - macOS:
Cmd+Enter(⌘Enter)
Behavior:
- Prevents default Enter behavior (new line)
- Applies changes to section
- Closes floating editor
- Updates rendered markdown
- Triggers
changes-acceptedevent
Example:
const editor = new TestDriveJSUI({ container: '#editor' });
editor.sectionManager.on('changes-accepted', (data) => {
console.log('Section updated via Ctrl+Enter');
console.log('New content:', data.content);
});
// User edits section, presses Ctrl+Enter
// → Changes applied, editor closes
Use cases:
- Fast editing workflow
- Apply changes without clicking Accept button
- Keyboard-only editing
Alternative: Click "✓ Accept" button
Escape (Cancel Section Edit)
Action: Cancel editing and discard changes
Platforms: All
Behavior:
- Restores original section content
- Closes floating editor
- No changes applied
- Triggers
changes-cancelledevent
Example:
// User clicks section, makes edits
// User presses Escape
// → Editor closes, original content restored
Use cases:
- Discard unwanted changes quickly
- Exit edit mode without saving
- Keyboard-only workflow
Alternative: Click "✗ Cancel" button
Tab (Indent)
Action: Insert tab character (4 spaces)
Platforms: All
Behavior:
- Inserts 4 spaces at cursor position
- Does not move focus to next element
- Useful for code blocks and lists
Example:
Before: |cursor here
After pressing Tab:
|cursor here
Use cases:
- Indent code in code blocks
- Create nested lists
- Format markdown content
Note: Most browsers use Tab to move focus. TestDrive-JSUI overrides this behavior within textareas.
Document Actions (Planned)
These shortcuts are planned for future releases.
Ctrl+P (Print Document)
Action: Open browser print dialog
Status: 🔜 Planned for v1.1
Platforms:
- Windows/Linux:
Ctrl+P - macOS:
Cmd+P(⌘P)
Expected behavior:
- Prevents browser's default print
- Formats document for printing
- Opens print preview dialog
Use cases:
- Quick print from editor
- Print formatted markdown
- Generate PDF via print
Ctrl+F (Find & Replace)
Action: Open find and replace dialog
Status: 🔜 Planned for v1.1
Platforms:
- Windows/Linux:
Ctrl+F - macOS:
Cmd+F(⌘F)
Expected behavior:
- Prevents browser's default find
- Opens TestDrive-JSUI find dialog
- Focuses search input field
- Highlights matches in document
Use cases:
- Search for text across document
- Replace repetitive content
- Navigate long documents
Text Formatting (Planned)
These shortcuts will be available when text is selected or cursor is in text.
Ctrl+B (Bold)
Action: Wrap selected text in **bold** markers
Status: 🔜 Planned for v1.1
Platforms:
- Windows/Linux:
Ctrl+B - macOS:
Cmd+B(⌘B)
Expected behavior:
Before: Selected text
After: **Selected text**
Use cases:
- Quick markdown formatting
- Bold emphasis in writing
- Keyboard-only formatting
Alternative: Click "B" button in Edit Control
Ctrl+I (Italic)
Action: Wrap selected text in *italic* markers
Status: 🔜 Planned for v1.1
Platforms:
- Windows/Linux:
Ctrl+I - macOS:
Cmd+I(⌘I)
Expected behavior:
Before: Selected text
After: *Selected text*
Use cases:
- Quick markdown formatting
- Italic emphasis in writing
- Keyboard-only formatting
Alternative: Click "I" button in Edit Control
Browser vs. Application Shortcuts
Conflicts
Some shortcuts conflict with browser defaults:
| Shortcut | Browser Default | TestDrive-JSUI |
|---|---|---|
Ctrl+S |
Browser save dialog | Document save |
Ctrl+P |
Browser print | Document print (planned) |
Ctrl+F |
Browser find | Document find (planned) |
Ctrl+B |
Bookmarks sidebar | Bold text (planned) |
Ctrl+I |
Open DevTools | Italic text (planned) |
Solution: TestDrive-JSUI calls event.preventDefault() to override browser behavior.
Preserving Browser Shortcuts
Some browser shortcuts remain available:
Ctrl+Z/Cmd+Z- Undo (within textareas)Ctrl+Y/Cmd+Shift+Z- Redo (within textareas)Ctrl+C/Cmd+C- CopyCtrl+V/Cmd+V- PasteCtrl+X/Cmd+X- CutCtrl+A/Cmd+A- Select allF5/Ctrl+R- Refresh pageF11- FullscreenF12- DevTools
Custom Shortcuts
You can add custom shortcuts by listening to keyboard events:
Example: Ctrl+E (Export)
const editor = new TestDriveJSUI({ container: '#editor' });
document.addEventListener('keydown', (event) => {
// Ctrl+E or Cmd+E
if ((event.ctrlKey || event.metaKey) && event.key === 'e') {
event.preventDefault();
// Custom export action
const markdown = editor.getMarkdown();
console.log('Export triggered:', markdown);
// Trigger export
if (editor.editControl) {
editor.editControl.exportDocument();
}
}
});
Example: Ctrl+Shift+D (Debug Toggle)
document.addEventListener('keydown', (event) => {
// Ctrl+Shift+D
if (event.ctrlKey && event.shiftKey && event.key === 'D') {
event.preventDefault();
// Toggle debug control
if (editor.debugControl) {
if (editor.debugControl.isExpanded) {
editor.debugControl.collapse();
} else {
editor.debugControl.expand();
}
}
}
});
Example: Ctrl+K (Insert Link)
document.addEventListener('keydown', (event) => {
if ((event.ctrlKey || event.metaKey) && event.key === 'k') {
event.preventDefault();
// Get active textarea
const activeTextarea = document.activeElement;
if (activeTextarea.tagName === 'TEXTAREA') {
// Insert link markdown
const selectedText = activeTextarea.value.substring(
activeTextarea.selectionStart,
activeTextarea.selectionEnd
);
const linkMarkdown = selectedText
? `[${selectedText}](url)`
: '[text](url)';
// Insert at cursor
const start = activeTextarea.selectionStart;
const end = activeTextarea.selectionEnd;
const text = activeTextarea.value;
activeTextarea.value = text.substring(0, start) + linkMarkdown + text.substring(end);
// Select 'url' part
const urlStart = start + linkMarkdown.indexOf('(') + 1;
const urlEnd = urlStart + 3;
activeTextarea.setSelectionRange(urlStart, urlEnd);
activeTextarea.focus();
}
}
});
Accessibility
Keyboard-Only Operation
All TestDrive-JSUI features are accessible via keyboard:
- Navigation: Tab through interactive elements
- Section editing: Enter to open, Escape to close
- Controls: Tab to reach, Space/Enter to activate
- Shortcuts: All documented shortcuts work
Screen Reader Support
Keyboard shortcuts work with screen readers:
- ARIA labels: All buttons have descriptive labels
- Focus management: Proper focus order maintained
- Announcements: State changes announced to screen readers
Example:
<button aria-label="Accept changes (Ctrl+Enter)">✓ Accept</button>
Custom Key Bindings
For users with accessibility needs:
const editor = new TestDriveJSUI({
container: '#editor',
shortcuts: false // Disable defaults
});
// Implement custom shortcuts matching user's needs
document.addEventListener('keydown', (event) => {
// Custom bindings here
});
Troubleshooting
Shortcut Not Working
Problem: Pressing shortcut does nothing
Solutions:
-
Check if shortcuts enabled:
console.log(editor.config.shortcuts); // Should be true -
Check browser extension conflicts:
- Disable extensions like Vimium, Shortkeys
- Test in incognito/private mode
-
Check operating system conflicts:
- Some OS shortcuts override browser shortcuts
- Example: Windows
Ctrl+Smight open system save dialog
-
Test with different modifier:
- Try
Cmdinstead ofCtrlon macOS - Try
Ctrlinstead ofCmdon Windows
- Try
-
Verify focus:
console.log(document.activeElement); // Check what has focus
Shortcut Conflicts
Problem: Shortcut triggers wrong action
Solutions:
-
Disable TestDrive-JSUI shortcuts:
new TestDriveJSUI({ shortcuts: false }); -
Implement custom shortcuts:
document.addEventListener('keydown', (event) => { // Your custom logic }); -
Check browser extensions: Disable conflicting extensions
macOS Specific Issues
Problem: Ctrl shortcuts don't work on macOS
Solution: Use Cmd (⌘) key instead:
Cmd+Sinstead ofCtrl+SCmd+Enterinstead ofCtrl+Enter
Code detects platform automatically:
if (event.ctrlKey || event.metaKey) { // metaKey = Cmd on Mac
// Handle shortcut
}
Best Practices
For Users
- Learn core shortcuts first: Ctrl+S, Escape, Ctrl+Enter
- Use shortcuts consistently: Build muscle memory
- Combine with mouse: Use whichever is faster for context
- Customize if needed: Add shortcuts for frequent actions
For Developers
- Document custom shortcuts: Provide cheat sheet to users
- Avoid conflicts: Check existing shortcuts before adding new
- Provide alternatives: Always offer mouse-based alternative
- Test across platforms: Verify shortcuts work on Windows, Mac, Linux
- Respect user settings: Allow disabling shortcuts if needed
Example: Shortcut Cheat Sheet
const editor = new TestDriveJSUI({ container: '#editor' });
// Add help button that shows shortcuts
const helpButton = document.createElement('button');
helpButton.textContent = 'Keyboard Shortcuts (?)';
helpButton.onclick = () => {
alert(`
TestDrive-JSUI Keyboard Shortcuts:
Ctrl+S - Save document
Escape - Close editor
Ctrl+Enter - Accept changes
Tab - Indent
More shortcuts: /docs/keyboard-shortcuts
`);
};
document.body.appendChild(helpButton);
Platform Differences
Windows/Linux
- Uses
Ctrlkey for shortcuts Altkey for alternative shortcuts- Standard keyboard layout
macOS
- Uses
Cmd(⌘) key instead ofCtrl Option(⌥) key instead ofAltControlkey rarely used for app shortcuts
Detection in Code
const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
document.addEventListener('keydown', (event) => {
const modifierPressed = isMac ? event.metaKey : event.ctrlKey;
if (modifierPressed && event.key === 's') {
// Save action
}
});
Future Shortcuts (Roadmap)
Planned for future versions:
Version 1.1
- ✅
Ctrl+P- Print document - ✅
Ctrl+F- Find & replace - ✅
Ctrl+B- Bold text - ✅
Ctrl+I- Italic text - ✅
Ctrl+K- Insert link - ✅
Ctrl+Shift+C- Insert code block
Version 1.2
- 🔜
Ctrl+H- Insert heading - 🔜
Ctrl+L- Insert list - 🔜
Ctrl+Shift+I- Insert image - 🔜
Ctrl+G- Go to line - 🔜
Ctrl+D- Duplicate line
Version 2.0
- 🔜
Ctrl+/- Toggle comment - 🔜
Ctrl+Shift+K- Delete line - 🔜
Ctrl+[/Ctrl+]- Indent/unindent - 🔜
Ctrl+Space- Autocomplete - 🔜
F3- Find next
Request features: Submit suggestions at GitHub Issues
Related Features
- Section Editing - Edit sections with keyboard
- Edit Control - Document actions and shortcuts
- Accessibility - Keyboard-only operation (coming soon)
See Also:
Version: 1.0.0 Last Updated: 2025-12-16