Skip to content

Commit

Permalink
Merge pull request arcxingye#21 from kifuan/kano
Browse files Browse the repository at this point in the history
添加键盘D,F,J,K操作的功能
  • Loading branch information
arcxingye authored Jan 24, 2022
2 parents 36517a8 + da7e140 commit 3ad4a5e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<div style="font-size:2.2em; color:#fff; line-height:1.5em;">
从最底下小鹿乃开始<br />
看看你20秒能多少分<br />
可以用D, F, J, K操作<br />
</div>
<br />
<div id="btn_group" style="display: block;">
Expand Down
33 changes: 28 additions & 5 deletions static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,32 @@ function goRank() {
}
window.location.href=link;
}
console.log("不修改,好嘛?乱传又有什么用呢?(ˉ▽ˉ;)...")
document.onkeydown = function (e) {
if (e.keyCode == 123) {
return false

function click(index) {
let p = _gameBBList[_gameBBListIndex];
let base = parseInt(document.getElementById(p.id).getAttribute("num")) - p.cell;
let num = base + index - 1;
let id = p.id.substring(0, 11) + num;

let fakeEvent = {
clientX: ((index - 1) * blockSize + index * blockSize) / 2,
// Make sure that it is in the area
clientY: (touchArea[0] + touchArea[1]) / 2,
target: document.getElementById(id),
};

gameTapEvent(fakeEvent)
}

document.onkeydown = function(e) {
const map = {
'd': 1, 'f': 2, 'j': 3, 'k': 4
}
};
let key = e.key.toLowerCase();

if (Object.keys(map).indexOf(key) !== -1) {
click(map[key])
}
}

console.log("不修改,好嘛?乱传又有什么用呢?(ˉ▽ˉ;)...")

0 comments on commit 3ad4a5e

Please sign in to comment.