Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1114)

Unified Diff: chrome/browser/resources/pdf/pdf.js

Issue 2358553002: PDF: Use KeyboardEvent.code instead of keyCode.
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/pdf/pdf.js
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index 2c802e687f637ce4b239f5572ef5dbb4b119b68d..df2e868a99e798ef84d3de1c55b5c4e83a697fb6 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -284,29 +284,29 @@ PDFViewer.prototype = {
}
}.bind(this);
- switch (e.keyCode) {
- case 9: // Tab key.
+ switch (e.code) {
+ case 'Tab':
this.toolbarManager_.showToolbarsForKeyboardNavigation();
return;
- case 27: // Escape key.
+ case 'Escape':
if (!this.isPrintPreview_) {
this.toolbarManager_.hideSingleToolbarLayer();
return;
}
break; // Ensure escape falls through to the print-preview handler.
- case 32: // Space key.
+ case 'Space':
if (e.shiftKey)
pageUpHandler();
else
pageDownHandler();
return;
- case 33: // Page up key.
+ case 'PageUp':
pageUpHandler();
return;
- case 34: // Page down key.
+ case 'PageDown':
pageDownHandler();
return;
- case 37: // Left arrow key.
+ case 'ArrowLeft':
if (!(e.altKey || e.ctrlKey || e.metaKey || e.shiftKey)) {
// Go to the previous page if there are no horizontal scrollbars and
// no form field is focused.
@@ -321,13 +321,13 @@ PDFViewer.prototype = {
}
}
return;
- case 38: // Up arrow key.
+ case 'ArrowUp':
if (fromScriptingAPI) {
position.y -= Viewport.SCROLL_INCREMENT;
this.viewport.position = position;
}
return;
- case 39: // Right arrow key.
+ case 'ArrowRight':
if (!(e.altKey || e.ctrlKey || e.metaKey || e.shiftKey)) {
// Go to the next page if there are no horizontal scrollbars and no
// form field is focused.
@@ -342,13 +342,13 @@ PDFViewer.prototype = {
}
}
return;
- case 40: // Down arrow key.
+ case 'ArrowDown':
if (fromScriptingAPI) {
position.y += Viewport.SCROLL_INCREMENT;
this.viewport.position = position;
}
return;
- case 65: // 'a' key.
+ case 'KeyA':
if (e.ctrlKey || e.metaKey) {
this.plugin_.postMessage({
type: 'selectAll'
@@ -357,21 +357,21 @@ PDFViewer.prototype = {
e.preventDefault();
}
return;
- case 71: // 'g' key.
+ case 'KeyG':
if (this.toolbar_ && (e.ctrlKey || e.metaKey) && e.altKey) {
this.toolbarManager_.showToolbars();
this.toolbar_.selectPageNumber();
}
return;
- case 219: // Left bracket key.
+ case 'BracketLeft':
if (e.ctrlKey)
this.rotateCounterClockwise_();
return;
- case 220: // Backslash key.
+ case 'Backslash':
if (e.ctrlKey)
this.zoomToolbar_.fitToggleFromHotKey();
return;
- case 221: // Right bracket key.
+ case 'BracketRight':
if (e.ctrlKey)
this.rotateClockwise_();
return;

Powered by Google App Engine
This is Rietveld 408576698