Keypress event changed to keydown. It allows to control the extension with different keyboard layouts.

This commit is contained in:
Кудров Алексей Владимирович
2016-02-11 14:38:45 +07:00
parent b0e49e4a34
commit 5d0011130f
2 changed files with 4 additions and 5 deletions

View File

@@ -155,11 +155,10 @@ chrome.extension.sendMessage({}, function(response) {
document.head.appendChild(link);
}
document.addEventListener('keypress', function(event) {
// if lowercase letter pressed, check for uppercase key code
var keyCode = String.fromCharCode(event.keyCode).toUpperCase().charCodeAt();
document.addEventListener('keydown', function(event) {
var keyCode = event.keyCode;
// Ignore keypress event if typing in an input box
// Ignore keydown event if typing in an input box
if ((document.activeElement.nodeName === 'INPUT'
&& document.activeElement.getAttribute('type') === 'text')
|| document.activeElement.isContentEditable) {

View File

@@ -113,7 +113,7 @@ function restore_defaults() {
function initShortcutInput(inputId) {
document.getElementById(inputId).addEventListener('focus', inputFocus);
document.getElementById(inputId).addEventListener('blur', inputBlur);
document.getElementById(inputId).addEventListener('keypress', recordKeyPress);
document.getElementById(inputId).addEventListener('keydown', recordKeyPress);
}
document.addEventListener('DOMContentLoaded', function () {