Skip to content

Commit 6d8c004

Browse files
committed
feat: remember binds locally
1 parent e11de27 commit 6d8c004

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

keypanel.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ function setModeBinding(key, val) {
4242
if (g_set_binds[key][0] === null && g_set_binds[key][1] === null) {
4343
delete g_set_binds[key];
4444
}
45+
46+
window.localStorage.setItem("keybinds", JSON.stringify(g_set_binds))
4547
}
4648

4749
let keys = document.getElementsByClassName("key");
@@ -214,6 +216,7 @@ document.getElementById("reset_bind").addEventListener("click", function() {
214216

215217
document.getElementById("reset_all").addEventListener("click", function() {
216218
g_set_binds = JSON.parse(JSON.stringify(g_default_binds));
219+
window.localStorage.clear();
217220

218221
updateBound();
219222
updateSelected();
@@ -259,3 +262,13 @@ document.getElementById("gen_cfg").addEventListener("click", function() {
259262
a.remove();
260263
}, 0);
261264
});
265+
266+
document.addEventListener("DOMContentLoaded", function() {
267+
let stored_binds = window.localStorage.getItem("keybinds");
268+
if (stored_binds !== null) {
269+
g_set_binds = JSON.parse(stored_binds);
270+
}
271+
272+
updateBound();
273+
updateSelected();
274+
});

0 commit comments

Comments
 (0)