Skip to content

Commit

Permalink
emulate java getKeyChar() that reduces value if ctrl pressed (#14)
Browse files Browse the repository at this point in the history
* emulate java getKeyChar() that reduces value if ctrl pressed

* make it self evident

* this seems to be accurate to java client

* Fixes #13
  • Loading branch information
lesleyrs authored May 29, 2024
1 parent 5653c3e commit d4421f0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/js/jagex2/client/GameShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ export default abstract class GameShell {
const code: number = mappedKey.code;
let ch: number = mappedKey.ch;

if (e.ctrlKey) {
if ((ch >= 'A'.charCodeAt(0) && ch <= ']'.charCodeAt(0)) || ch == '_'.charCodeAt(0)) {
ch -= 'A'.charCodeAt(0) - 1;
} else if (ch >= 'a'.charCodeAt(0) && ch <= 'z'.charCodeAt(0)) {
ch -= 'a'.charCodeAt(0) - 1;
}
}

if (ch < 30) {
ch = 0;
}
Expand Down

0 comments on commit d4421f0

Please sign in to comment.