I'm currently working on a "game", in which I'm encountering trouble with the controls. I'm currently using numerical keyCode values (because they seem more efficient and pretty to me), although nothing seems to happen when trying to bind the following keys with the following values: & with 49, é with 50, " with 222.
I got the codes from http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes and these are the first problems I encountered with these.
As a side note, I'm using a Mac and an AZERTY-keyboard.
Thanks in advance,
Actual code:
void keyPressed() {
if (mode == "azerty") {
if (key == CODED) {
if (keyCode == 38) {
keybool[0] = true;
}
else if (keyCode == 40) {
keybool[1] = true;
}
if (keyCode == 37) {
keybool[2] = true;
}
else if (keyCode == 39) {
keybool[3] = true;
}
if (keyCode == 16) {
keybool[4] = true;
}
if (keyCode == 49) {
keybool[5] = true;
}
if (keyCode == 50) {
keybool[6] = true;
}
if (keyCode == 222) {
keybool[7] = true;
}
}
}
}
void keyReleased() {
if (mode == "azerty") {
if (key == CODED) {
if (keyCode == 38) {
keybool[0] = false;
}
else if (keyCode == 40) {
keybool[1] = false;
}
if (keyCode == 37) {
keybool[2] = false;
}
else if (keyCode == 39) {
keybool[3] = false;
}
if (keyCode == 16) {
keybool[4] = false;
}
if (keyCode == 49) {
keybool[5] = false;
}
else if (keyCode == 50) {
keybool[6] = false;
}
else if (keyCode == 222) {
keybool[7] = false;
}
}
}
}
void keyFunc() {
if (keybool[0]) {
player.move(1);
}
else if (keybool[1]) {
player.move(-1);
}
if (keybool[2]) {
player.turn(-0.5);
}
else if (keybool[3]) {
player.turn(0.5);
}
if (keybool[4]) {
}
if (keybool[5]) {
player.attack(0);
}
else if (keybool[6]) {
player.attack(1);
}
else if (keybool[7]) {
player.attack(2);
}
}
void attack(int attackNum) {
if (attackNum == 0) {
println("SLASH!");
} else if (attackNum == 1) {
println("STAB!");
} else if (attackNum == 2) {
println("PUMMEL!");
}
}