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

Unified Diff: chrome/browser/resources/md_downloads/crisper.js

Issue 2104103002: Convert Event#keyIdentifier (deprecated) to Event#key (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch file manager test Created 4 years, 5 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/md_downloads/crisper.js
diff --git a/chrome/browser/resources/md_downloads/crisper.js b/chrome/browser/resources/md_downloads/crisper.js
index d9ca3b4e809a97a652e758bd2aabbd646c70f3f7..d0019b729dba518417f5ca5c412a310bbc8f6276 100644
--- a/chrome/browser/resources/md_downloads/crisper.js
+++ b/chrome/browser/resources/md_downloads/crisper.js
@@ -839,7 +839,7 @@ cr.define('cr.ui', function() {
function KeyboardShortcut(shortcut) {
var mods = {};
var ident = '';
- shortcut.split('-').forEach(function(part) {
+ shortcut.split('|').forEach(function(part) {
var partLc = part.toLowerCase();
switch (partLc) {
case 'alt':
@@ -866,7 +866,7 @@ cr.define('cr.ui', function() {
* @return {boolean} Whether we found a match or not.
*/
matchesEvent: function(e) {
- if (e.keyIdentifier == this.ident_) {
+ if (e.key == this.ident_) {
// All keyboard modifiers needs to match.
var mods = this.mods_;
return ['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].every(function(k) {
@@ -927,17 +927,17 @@ cr.define('cr.ui', function() {
/**
* The keyboard shortcut that triggers the command. This is a string
- * consisting of a keyIdentifier (as reported by WebKit in keydown) as
- * well as optional key modifiers joinded with a '-'.
+ * consisting of a key (as reported by WebKit in keydown) as
+ * well as optional key modifiers joinded with a '|'.
*
* Multiple keyboard shortcuts can be provided by separating them by
* whitespace.
*
* For example:
* "F1"
- * "U+0008-Meta" for Apple command backspace.
- * "U+0041-Ctrl" for Control A
- * "U+007F U+0008-Meta" for Delete and Command Backspace
+ * "Backspace-Meta" for Apple command backspace.
+ * "a-Ctrl" for Control A
+ * "Delete Backspace-Meta" for Delete and Command Backspace
*
* @type {string}
*/
@@ -1714,8 +1714,7 @@ function quoteString(str) {
/**
* Special table for KeyboardEvent.keyCode.
- * KeyboardEvent.keyIdentifier is better, and KeyBoardEvent.key is even better
- * than that.
+ * KeyBoardEvent.key is even better than that.
*
* Values from: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode#Value_of_keyCode
*/
@@ -1759,11 +1758,6 @@ function quoteString(str) {
var KEY_CHAR = /[a-z0-9*]/;
/**
- * Matches a keyIdentifier string.
- */
- var IDENT_CHAR = /U\+/;
-
- /**
* Matches arrow keys in Gecko 27.0+
*/
var ARROW_KEY = /^arrow/;
@@ -1811,21 +1805,6 @@ function quoteString(str) {
return validKey;
}
- function transformKeyIdentifier(keyIdent) {
- var validKey = '';
- if (keyIdent) {
- if (keyIdent in KEY_IDENTIFIER) {
- validKey = KEY_IDENTIFIER[keyIdent];
- } else if (IDENT_CHAR.test(keyIdent)) {
- keyIdent = parseInt(keyIdent.replace('U+', '0x'), 16);
- validKey = String.fromCharCode(keyIdent).toLowerCase();
- } else {
- validKey = keyIdent.toLowerCase();
- }
- }
- return validKey;
- }
-
function transformKeyCode(keyCode) {
var validKey = '';
if (Number(keyCode)) {
@@ -1860,10 +1839,9 @@ function quoteString(str) {
* To get @ returned, set noSpecialChars = false
*/
function normalizedKeyForEvent(keyEvent, noSpecialChars) {
- // Fall back from .key, to .keyIdentifier, to .keyCode, and then to
+ // Fall back from .key, to .keyCode, and then to
// .detail.key to support artificial keyboard events.
return transformKey(keyEvent.key, noSpecialChars) ||
- transformKeyIdentifier(keyEvent.keyIdentifier) ||
transformKeyCode(keyEvent.keyCode) ||
transformKey(keyEvent.detail ? keyEvent.detail.key : keyEvent.detail, noSpecialChars) || '';
}
@@ -4178,7 +4156,7 @@ var ActionLink = document.registerElement('action-link', {
this.setAttribute('role', 'link');
this.addEventListener('keydown', function(e) {
- if (!this.disabled && e.keyIdentifier == 'Enter' && !this.href) {
+ if (!this.disabled && e.key == 'Enter' && !this.href) {
// Schedule a click asynchronously because other 'keydown' handlers
// may still run later (e.g. document.addEventListener('keydown')).
// Specifically options dialogs break when this timeout isn't here.
@@ -11546,4 +11524,4 @@ cr.define('downloads', function() {
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-window.addEventListener('load', downloads.Manager.onLoad);
+window.addEventListener('load', downloads.Manager.onLoad);
« no previous file with comments | « chrome/browser/resources/chromeos/wallpaper_manager/main.html ('k') | chrome/browser/resources/md_downloads/downloads.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698