Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

Focus search box on ctrl+f

Russ Garrettfdc7251bceaa
diff --git a/web/src/geocoder.ts b/web/src/geocoder.ts
index d32f571..d63e2be 100644
--- a/web/src/geocoder.ts
+++ b/web/src/geocoder.ts
@@ -103,6 +103,14 @@ export default class OpenInfraMapGeocoder implements IControl {
)
]
})
+
+ // Focus on ctrl+f/cmd+f
+ document.addEventListener('keydown', (e) => {
+ if (e.key === 'f' && (e.ctrlKey || e.metaKey)) {
+ e.preventDefault()
+ this.container?.querySelector('input')?.focus()
+ }
+ })
return this.container
}