@@ -13,6 +13,7 @@ const UserInputModal = (userInputRequest: UserInputRequest) => {
1313 const [ responseText , setResponseText ] = useState ( "" ) ;
1414 const [ countdown , setCountdown ] = useState ( Math . floor ( userInputRequest . timeoutms / 1000 ) ) ;
1515 const checkboxRef = useRef < HTMLInputElement > ( null ) ;
16+ const [ capsLockOn , setCapsLockOn ] = useState ( false ) ;
1617
1718 const handleSendErrResponse = useCallback ( ( ) => {
1819 fireAndForget ( ( ) =>
@@ -73,11 +74,15 @@ const UserInputModal = (userInputRequest: UserInputRequest) => {
7374 handleSubmit ( ) ;
7475 return true ;
7576 }
76- return false ;
77+ return false ;
7778 } ,
7879 [ handleSendErrResponse , handleSubmit ]
7980 ) ;
8081
82+ const handleCapsLockCheck = useCallback ( ( e : React . KeyboardEvent < HTMLInputElement > ) => {
83+ setCapsLockOn ( e . getModifierState ( "CapsLock" ) ?? false ) ;
84+ } , [ ] ) ;
85+
8186 const queryText = useMemo ( ( ) => {
8287 if ( userInputRequest . markdown ) {
8388 return < Markdown text = { userInputRequest . querytext } /> ;
@@ -97,10 +102,21 @@ const UserInputModal = (userInputRequest: UserInputRequest) => {
97102 maxLength = { 400 }
98103 className = "resize-none bg-panel rounded-md border border-border py-1.5 pl-4 min-h-[30px] text-inherit cursor-text focus:ring-2 focus:ring-accent focus:outline-none"
99104 autoFocus = { true }
100- onKeyDown = { ( e ) => keyutil . keydownWrapper ( handleKeyDown ) ( e ) }
105+ onKeyDown = { ( e ) => {
106+ handleCapsLockCheck ( e ) ;
107+ keyutil . keydownWrapper ( handleKeyDown ) ( e ) ;
108+ } }
109+ onKeyUp = { handleCapsLockCheck }
101110 />
102111 ) ;
103- } , [ userInputRequest . responsetype , userInputRequest . publictext , responseText , handleKeyDown , setResponseText ] ) ;
112+ } , [
113+ userInputRequest . responsetype ,
114+ userInputRequest . publictext ,
115+ responseText ,
116+ handleKeyDown ,
117+ setResponseText ,
118+ handleCapsLockCheck ,
119+ ] ) ;
104120
105121 const optionalCheckbox = useMemo ( ( ) => {
106122 if ( userInputRequest . checkboxmsg == "" ) {
@@ -115,7 +131,9 @@ const UserInputModal = (userInputRequest: UserInputRequest) => {
115131 className = "accent-accent cursor-pointer"
116132 ref = { checkboxRef }
117133 />
118- < label htmlFor = { `uicheckbox-${ userInputRequest . requestid } ` } className = "cursor-pointer" > { userInputRequest . checkboxmsg } </ label >
134+ < label htmlFor = { `uicheckbox-${ userInputRequest . requestid } ` } className = "cursor-pointer" >
135+ { userInputRequest . checkboxmsg }
136+ </ label >
119137 </ div >
120138 </ div >
121139 ) ;
@@ -159,6 +177,9 @@ const UserInputModal = (userInputRequest: UserInputRequest) => {
159177 < div className = "flex flex-col justify-between gap-4 mx-4 mb-4 max-w-[500px] font-mono text-primary" >
160178 { queryText }
161179 { inputBox }
180+ { ! userInputRequest . publictext && capsLockOn && (
181+ < div className = "text-xs text-warning" > Caps Lock is ON</ div >
182+ ) }
162183 { optionalCheckbox }
163184 </ div >
164185 </ Modal >
0 commit comments