Files
corner/assets/utils.d850d3a8.js
T

2 lines
901 B
JavaScript

import{V as a}from"./index.eb79f5fd.js";function d(i,e,t=1){const n=e!==void 0?i:0;if(e=e!==void 0?e:i,e==n)return[];const s=e>n?1:-1;return[...Array(Math.floor(Math.abs(e-n)/t))].map((o,r)=>n+r*t*s)}function u(i,e,t){return i>t?t:i<e?e:i}class c extends a{constructor(){super(...arguments),this.keybinds={},this._keybinds={}}initKeybinds(){}mounted(){document.addEventListener("keydown",this.keyListener),this.initKeybinds(),Object.keys(this.keybinds).forEach(e=>this._keybinds[e.toLowerCase()]=this.keybinds[e])}unmounted(){document.removeEventListener("keydown",this.keyListener)}keyListener(e){let t=e.key;e.shiftKey&&(t="Shift"+t),e.altKey&&(t="Alt"+t),e.ctrlKey&&(t="Ctrl"+t),e.metaKey&&(t="Cmd"+t),t=t.toLowerCase(),console.log(t),t in this._keybinds&&this._keybinds[t](e)!==!1&&e.preventDefault()}}function f(i){return i.charAt(0).toUpperCase()+i.slice(1)}export{c as K,f as c,u as m,d as r};