File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -1149,11 +1149,38 @@ module ControlPanel = {
1149
1149
| _ => false
1150
1150
}
1151
1151
1152
+ let onKeyDown = event => {
1153
+ switch (
1154
+ event -> ReactEvent .Keyboard .metaKey || event -> ReactEvent .Keyboard .ctrlKey ,
1155
+ event -> ReactEvent .Keyboard .key ,
1156
+ ) {
1157
+ | (true , "e" ) => dispatch (RunCode )
1158
+ | _ => ()
1159
+ }
1160
+ }
1161
+
1162
+ React .useEffect (() => {
1163
+ Webapi .Window .addEventListener ("keydown" , onKeyDown )
1164
+ Some (() => Webapi .Window .removeEventListener ("keydown" , onKeyDown ))
1165
+ }, [])
1166
+
1167
+ let runButtonText = {
1168
+ let userAgent = Webapi .Window .Navigator .userAgent
1169
+ let run = "Run"
1170
+ if userAgent -> String .includes ("iPhone" ) || userAgent -> String .includes ("Android" ) {
1171
+ run
1172
+ } else if userAgent -> String .includes ("Mac" ) {
1173
+ ` ${run} (⌘ + E)`
1174
+ } else {
1175
+ ` ${run} (Ctrl + E)`
1176
+ }
1177
+ }
1178
+
1152
1179
<div className = "flex flex-row gap-x-2" >
1153
1180
<ToggleButton checked = autoRun onChange = {_ => dispatch (ToggleAutoRun )}>
1154
1181
{React .string ("Auto-run" )}
1155
1182
</ToggleButton >
1156
- <Button onClick = {_ => dispatch (RunCode )}> {React .string ("Run" )} </Button >
1183
+ <Button onClick = {_ => dispatch (RunCode )}> {React .string (runButtonText )} </Button >
1157
1184
<Button onClick = onFormatClick > {React .string ("Format" )} </Button >
1158
1185
<ShareButton actionIndicatorKey />
1159
1186
</div >
Original file line number Diff line number Diff line change @@ -62,6 +62,10 @@ module Window = {
62
62
module Location = {
63
63
@scope (("window" , "location" )) @val external href : string = "href"
64
64
}
65
+
66
+ module Navigator = {
67
+ @scope (("window" , "navigator" )) @val external userAgent : string = "userAgent"
68
+ }
65
69
}
66
70
67
71
module Fetch = {
You can’t perform that action at this time.
0 commit comments