mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
Keyboard fixes
This commit is contained in:
parent
0903d0a25c
commit
9e4da2c153
@ -728,6 +728,7 @@ function _keydown(evt) {
|
||||
}
|
||||
} else if (evt.keyCode == 16) { // Shift
|
||||
keyboard.shiftKey(true);
|
||||
io.buttonDown(2, true);
|
||||
} else if (evt.keyCode == 17) { // Control
|
||||
keyboard.controlKey(true);
|
||||
} else if (!focused && (!evt.metaKey || evt.ctrlKey)) {
|
||||
@ -747,6 +748,7 @@ function _keyup(evt) {
|
||||
|
||||
if (evt.keyCode == 16) { // Shift
|
||||
keyboard.shiftKey(false);
|
||||
io.buttonDown(2, false);
|
||||
} else if (evt.keyCode == 17) { // Control
|
||||
keyboard.controlKey(false);
|
||||
} else {
|
||||
@ -842,8 +844,8 @@ $(function() {
|
||||
.mousemove(_mousemove)
|
||||
.bind("contextmenu", function(e) { e.preventDefault(); });
|
||||
|
||||
$("input,textarea").focus(function() { focused = true; });
|
||||
$("input,textarea").blur(function() { focused = false; });
|
||||
$("input,textarea").focus(function() { focused = true; })
|
||||
.blur(function() { focused = false; });
|
||||
|
||||
keyboard.create($("#keyboard"));
|
||||
|
||||
|
@ -704,6 +704,17 @@ function loadLocalStorage(drive, name) {
|
||||
|
||||
var _key;
|
||||
function _keydown(evt) {
|
||||
if (!focused) {
|
||||
evt.preventDefault();
|
||||
|
||||
var key = keyboard.mapKeyEvent(evt);
|
||||
if (key != 0xff) {
|
||||
if (_key != 0xff) io.keyUp();
|
||||
io.keyDown(key, evt.shiftKey);
|
||||
_key = key;
|
||||
}
|
||||
}
|
||||
|
||||
if (evt.keyCode === 112) { // F1 - Reset
|
||||
cpu.reset();
|
||||
} else if (evt.keyCode === 113) { // F2 - Full Screen
|
||||
@ -727,31 +738,31 @@ function _keydown(evt) {
|
||||
}
|
||||
} else if (evt.keyCode == 16) { // Shift
|
||||
keyboard.shiftKey(true);
|
||||
io.buttonDown(2, true);
|
||||
} else if (evt.keyCode == 17) { // Control
|
||||
keyboard.controlKey(true);
|
||||
} else if (!focused && (!evt.metaKey || evt.ctrlKey)) {
|
||||
evt.preventDefault();
|
||||
|
||||
var key = keyboard.mapKeyEvent(evt);
|
||||
if (key != 0xff) {
|
||||
if (_key != 0xff) io.keyUp();
|
||||
io.keyDown(key);
|
||||
_key = key;
|
||||
}
|
||||
} else if (evt.keyCode == 91 || evt.keyCode == 93) { // Command
|
||||
keyboard.commandKey(true);
|
||||
} else if (evt.keyCode == 18) { // Alt
|
||||
keyboard.optionKey(true);
|
||||
}
|
||||
}
|
||||
|
||||
function _keyup(evt) {
|
||||
_key = 0xff;
|
||||
|
||||
if (!focused)
|
||||
io.keyUp();
|
||||
|
||||
if (evt.keyCode == 16) { // Shift
|
||||
keyboard.shiftKey(false);
|
||||
io.buttonDown(2, false);
|
||||
} else if (evt.keyCode == 17) { // Control
|
||||
keyboard.controlKey(false);
|
||||
} else {
|
||||
if (!focused) {
|
||||
io.keyUp();
|
||||
}
|
||||
} else if (evt.keyCode == 91 || evt.keyCode == 93) { // Command
|
||||
keyboard.commandKey(false);
|
||||
} else if (evt.keyCode == 18) { // Alt
|
||||
keyboard.optionKey(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -841,6 +852,9 @@ $(function() {
|
||||
.mousemove(_mousemove)
|
||||
.bind("contextmenu", function(e) { e.preventDefault(); });
|
||||
|
||||
$("body > div").hover(function() { focused = false; },
|
||||
function() { focused = true; });
|
||||
|
||||
$("input,textarea").focus(function() { focused = true; });
|
||||
$("input,textarea").blur(function() { focused = false; });
|
||||
|
||||
|
BIN
img/closed-apple24-green.png
Normal file
BIN
img/closed-apple24-green.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 487 B |
BIN
img/closed-apple24.png
Normal file
BIN
img/closed-apple24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 422 B |
BIN
img/open-apple24-green.png
Normal file
BIN
img/open-apple24-green.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 569 B |
BIN
img/open-apple24.png
Normal file
BIN
img/open-apple24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 503 B |
@ -253,11 +253,11 @@ function KeyBoard(io) {
|
||||
return span;
|
||||
}
|
||||
|
||||
function _mouseup() {
|
||||
$(this).removeClass("pressed");
|
||||
function _mouseup(ev) {
|
||||
$(ev.currentTarget).removeClass("pressed");
|
||||
}
|
||||
|
||||
function _mousedown() {
|
||||
function _mousedown(ev) {
|
||||
$(this).addClass("pressed");
|
||||
var key = $(ev.currentTarget).data(shifted ? "key2" : "key1");
|
||||
switch (key) {
|
||||
|
Loading…
Reference in New Issue
Block a user