lost-sia
Version:
Single Image Annotation Tool
2 lines (1 loc) • 1.74 kB
JavaScript
const o="editLabel",t="deleteAnno",n="enterAnnoAddMode",i="leaveAnnoAddMode",s="undo",r="redo",c="traverseAnnos",a="camMoveUp",A="camMoveDown",g="camMoveLeft",h="camMoveRight",D="camMoveStop",E="copyAnnotation",_="pasteAnnotation",N="recreateAnnotation",O="deleteAnnoInCreation",l="toggleAnnoCommentInput";class k{constructor(e=void 0){this.controlDown=!1,this.shiftDown=!1,this.keyActionHandler=e}keyDown(e){switch(e){case"Enter":this.triggerKeyAction(o);break;case"Delete":this.triggerKeyAction(t);break;case"Backspace":this.triggerKeyAction(t);break;case"Control":this.controlDown=!0,this.triggerKeyAction(n);break;case"Shift":this.shiftDown=!0;break;case"z":this.controlDown&&this.triggerKeyAction(s);break;case"r":this.controlDown&&this.triggerKeyAction(r);break;case"Tab":this.triggerKeyAction(c);break;case"w":this.triggerKeyAction(a);break;case"s":this.triggerKeyAction(A);break;case"a":this.triggerKeyAction(g);break;case"d":this.triggerKeyAction(h);break;case"e":this.triggerKeyAction(N);break;case"c":this.controlDown?this.triggerKeyAction(E):this.triggerKeyAction(l);break;case"v":this.controlDown&&this.triggerKeyAction(_);break;case"Escape":this.triggerKeyAction(O);break}}keyUp(e){switch(e){case"Control":this.controlDown=!1,this.triggerKeyAction(i);break;case"Shift":this.shiftDown=!1;break}}triggerKeyAction(e){this.keyActionHandler&&this.keyActionHandler(e)}}export{A as CAM_MOVE_DOWN,g as CAM_MOVE_LEFT,h as CAM_MOVE_RIGHT,D as CAM_MOVE_STOP,a as CAM_MOVE_UP,E as COPY_ANNOTATION,t as DELETE_ANNO,O as DELETE_ANNO_IN_CREATION,o as EDIT_LABEL,n as ENTER_ANNO_ADD_MODE,i as LEAVE_ANNO_ADD_MODE,_ as PASTE_ANNOTATION,N as RECREATE_ANNO,r as REDO,l as TOGGLE_ANNO_COMMENT_INPUT,c as TRAVERSE_ANNOS,s as UNDO,k as default};