Allow ctrl-keys as well as plain ones

This commit is contained in:
Eric Fredricksen
2022-01-20 22:42:37 -08:00
parent 9efa64a0ce
commit 1b68a0ecff
+9 -15
View File
@@ -1172,26 +1172,20 @@ window.onerror = function(message, source, lineno, colno, error) {
function FormKeyDown(e) { function FormKeyDown(e) {
$("#bsodmom").hide(); $("#bsodmom").hide();
var key = String.fromCharCode(e.which); if (e.key === 'd') {
if (key === 'd') {
alert("Your character's genome is " + ToDna(game.dna + "")); alert("Your character's genome is " + ToDna(game.dna + ""));
} }
// if (key === 'e') {
// simulateanerror();
// }
if (game.online) { if (game.online) {
if (key === 'b') { if (e.key === 'b') {
Brag('b', true); Brag('b', true);
} }
if (key === 'g') { if (e.key === 'g') {
Guildify(InputBox('Choose a guild.\n\nMake sure you undestand the guild rules before you join one. To learn more about guilds, visit http://progressquest.com/guilds.php\n', game.guild)); Guildify(InputBox('Choose a guild.\n\nMake sure you undestand the guild rules before you join one. To learn more about guilds, visit http://progressquest.com/guilds.php\n', game.guild));
} }
if (key === 'm') { if (e.key === 'm') {
let mot = InputBox('Declare your motto!', game.motto); let mot = InputBox('Declare your motto!', game.motto);
if (mot !== null) { if (mot !== null) {
game.motto = mot; game.motto = mot;
@@ -1200,7 +1194,7 @@ function FormKeyDown(e) {
} }
} }
if (key === 'p') { if (e.key === 'p') {
if (clock && clock.running) { if (clock && clock.running) {
$('#paused').css('display', 'block'); $('#paused').css('display', 'block');
StopTimer(); StopTimer();
@@ -1210,16 +1204,16 @@ function FormKeyDown(e) {
} }
} }
if (key === 'q') { if (e.key === 'q') {
quit(); quit();
} }
if (key === 's') { if (e.key === 's') {
SaveGame(); SaveGame();
alert('Saved (' + JSON.stringify(game).length + ' bytes).'); alert('Saved (' + JSON.stringify(game).length + ' bytes).');
} }
if (key === 'w') { if (e.key === 'w') {
if (window.opener) return; if (window.opener) return;
$(window).unbind('unload'); // we're about to save it anyway $(window).unbind('unload'); // we're about to save it anyway
SaveGame(() => { SaveGame(() => {
@@ -1234,7 +1228,7 @@ function FormKeyDown(e) {
} }
/* /*
if (key === 't') { if (e.key === 't') {
TaskBar.reposition(TaskBar.Max()); TaskBar.reposition(TaskBar.Max());
} }
*/ */