Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion src/common/keyboard-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class KeyboardManager {

let key = getKeyCombination(event);
let code = getCodeCombination(event);
let textSelectionPopup = this._reader._state.primaryViewSelectionPopup || this._reader._state.secondaryViewSelectionPopup;

let sidebarAnnotationFocused = document.activeElement.classList.contains('annotation');
let readAloudActive = this._reader._state.readAloudState.active;
Expand Down Expand Up @@ -356,6 +357,35 @@ export class KeyboardManager {
}

if (!isTextBox(event.target)) {
if (textSelectionPopup) {
if (key === 'h') {
event.preventDefault();
event.stopPropagation();
this._reader.setTextSelectionAnnotationMode('highlight');
return;
}
else if (key === 'u') {
event.preventDefault();
event.stopPropagation();
this._reader.setTextSelectionAnnotationMode('underline');
return;
}
else if (code.startsWith('Digit')) {
let idx = parseInt(code.slice(5)) - 1;
if (ANNOTATION_COLORS[idx]) {
event.preventDefault();
event.stopPropagation();
this._reader._annotationManager.addAnnotation({
...textSelectionPopup.annotation,
type: this._reader._state.textSelectionAnnotationMode,
color: ANNOTATION_COLORS[idx][1]
});
this._reader.setSelectedAnnotations([]);
return;
}
}
}

if (code === 'Alt-Digit1') {
this._reader.toggleTool('highlight');
}
Expand Down Expand Up @@ -396,7 +426,7 @@ export class KeyboardManager {
this._reader.setTool({ color: ANNOTATION_COLORS[idx][1] });
}
}
else if (this._reader._type === 'pdf' && key === 'h' && !this._reader._state.readAloudState.active) {
else if (this._reader._type === 'pdf' && key === 'h' && !textSelectionPopup && !readAloudActive) {
this._reader.toggleHandTool();
}
else if (this._reader._type === 'pdf' && key === 's') {
Expand Down