Skip to content

Commit 1edabde

Browse files
authored
Move ctrlBindings check into constructor
1 parent 979d728 commit 1edabde

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const ctrlBindings = !!navigator.userAgent.match(/Macintosh/)
2-
31
export default class Combobox {
42
isComposing: boolean
53
list: HTMLElement
@@ -17,7 +15,9 @@ export default class Combobox {
1715
list.id = `combobox-${Math.random().toString().slice(2, 6)}`
1816
}
1917

20-
this.keyboardEventHandler = event => keyboardBindings(event, this)
18+
const ctrlBindings = !!navigator.userAgent.match(/Macintosh/)
19+
20+
this.keyboardEventHandler = event => keyboardBindings(event, this, ctrlBindings)
2121
this.compositionEventHandler = event => trackComposition(event, this)
2222
this.inputHandler = this.clearSelection.bind(this)
2323
input.setAttribute('role', 'combobox')
@@ -95,7 +95,7 @@ export default class Combobox {
9595
}
9696
}
9797

98-
function keyboardBindings(event: KeyboardEvent, combobox: Combobox) {
98+
function keyboardBindings(event: KeyboardEvent, combobox: Combobox, ctrlBindings: boolean) {
9999
if (event.shiftKey || event.metaKey || event.altKey) return
100100
if (!ctrlBindings && event.ctrlKey) return
101101
if (combobox.isComposing) return

0 commit comments

Comments
 (0)