Skip to content

Commit

Permalink
replace event.keyCode with event.code
Browse files Browse the repository at this point in the history
  • Loading branch information
mengwong committed Mar 5, 2023
1 parent bb37a47 commit 4efdf40
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/plugins/blackout/blackout.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
gc.addEventListener( document, "keydown", function( event ) {

// Accept b or . -> . is sent by presentation remote controllers
if ( [ "KeyB", "Period" ].includes(event.key) {
if ( [ "KeyB", "Period" ].includes(event.code) ) {
event.preventDefault();
if ( !blackedOut ) {
blackout();
Expand All @@ -105,7 +105,7 @@
gc.addEventListener( document, "keyup", function( event ) {

// Accept b or . -> . is sent by presentation remote controllers
if ( [ "KeyB", "Period" ].includes(event.key) {
if ( [ "KeyB", "Period" ].includes(event.code) ) {
event.preventDefault();
}
}, false );
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/goto/goto.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

// Don't return, allow the other categories to work despite this error
} else {
var index = keylist.indexOf( event.origEvent.key );
var index = keylist.indexOf( event.origEvent.code );
if ( index >= 0 ) {
var next = nextlist[ index ];
if ( isNumber( next ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/help/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
document.addEventListener( "keyup", function( event ) {

// "h" || "?" -- but this seems brittle, what about keyboards that don't have / ? together?
if ( [ "KeyH", "Slash" ].includes(event.key) ) {
if ( [ "KeyH", "Slash" ].includes(event.code) ) {
event.preventDefault();
toggleHelp();
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/impressConsole/impressConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,15 @@
// Prevent default keydown action when one of supported key is pressed
window.document.addEventListener( 'keydown', function( event ) {
if ( !event.ctrlKey && !event.altKey && !event.shiftKey && !event.metaKey &&
keys.includes( event.key ) ) {
keys.includes( event.code ) ) {
event.preventDefault();
}
}, false );

// Trigger impress action on keyup
window.document.addEventListener( 'keyup', function( event ) {
if ( !event.ctrlKey && !event.altKey && !event.shiftKey && !event.metaKey &&
keys.includes( event.key) ) {
keys.includes( event.code) ) {
handler();
event.preventDefault();
}
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/navigation/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

// In the case of TAB, we force step navigation always, overriding the browser
// navigation between input elements, buttons and links.
if ( event.key === "Tab" ) {
if ( event.code === "Tab" ) {
return true;
}

Expand All @@ -68,7 +68,7 @@
}

if ( "Space PageUp PageDown ArrowLeft ArrowRight ArrowUp ArrowDown"
.split(" ").includes(event.key) ) {
.split(" ").includes(event.code) ) {
return true;
}
};
Expand All @@ -86,13 +86,13 @@
gc.addEventListener( document, "keyup", function( event ) {
if ( isNavigationEvent( event ) ) {
if ( event.shiftKey ) {
switch ( event.key ) {
switch ( event.code ) {
case "Tab": // Shift+tab
api.prev();
break;
}
} else {
switch ( event.key ) {
switch ( event.code ) {
case "PageUp":
case "ArrowLeft":
case "ArrowUp": api.prev( event ); break;
Expand Down

0 comments on commit 4efdf40

Please sign in to comment.