You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
1.2 KiB
1 lines
1.2 KiB
import{h as m}from"./utils-BKyMmInE.js";import{a as r,o as c}from"./delegate-CI_DDEu_.js";import{D as y,W as h,S as w,V as b,t as v}from"./index-bVOhw2NF.js";function g(p={},n){const t=y({ctrl:!1,command:!1,win:!1,shift:!1,tab:!1}),{keydown:i,keyup:u}=p,s=e=>{switch(e.key){case"Control":t.ctrl=!0;break;case"Meta":t.command=!0,t.win=!0;break;case"Shift":t.shift=!0;break;case"Tab":t.tab=!0;break}i!==void 0&&Object.keys(i).forEach(o=>{if(o!==e.key)return;const a=i[o];if(typeof a=="function")a(e);else{const{stop:d=!1,prevent:l=!1}=a;d&&e.stopPropagation(),l&&e.preventDefault(),a.handler(e)}})},f=e=>{switch(e.key){case"Control":t.ctrl=!1;break;case"Meta":t.command=!1,t.win=!1;break;case"Shift":t.shift=!1;break;case"Tab":t.tab=!1;break}u!==void 0&&Object.keys(u).forEach(o=>{if(o!==e.key)return;const a=u[o];if(typeof a=="function")a(e);else{const{stop:d=!1,prevent:l=!1}=a;d&&e.stopPropagation(),l&&e.preventDefault(),a.handler(e)}})},k=()=>{(n===void 0||n.value)&&(c("keydown",document,s),c("keyup",document,f)),n!==void 0&&v(n,e=>{e?(c("keydown",document,s),c("keyup",document,f)):(r("keydown",document,s),r("keyup",document,f))})};return m()?(h(k),w(()=>{(n===void 0||n.value)&&(r("keydown",document,s),r("keyup",document,f))})):k(),b(t)}export{g as u};
|