diff --git a/src/utils.ts b/src/utils.ts
index 179c759..ac1c18d 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -8,7 +8,12 @@ export function isFormField(element: Node): boolean {
return (
name === 'select' ||
name === 'textarea' ||
- (name === 'input' && type !== 'submit' && type !== 'reset' && type !== 'checkbox' && type !== 'radio') ||
+ (name === 'input' &&
+ type !== 'submit' &&
+ type !== 'reset' &&
+ type !== 'checkbox' &&
+ type !== 'radio' &&
+ type !== 'file') ||
element.isContentEditable
)
}
diff --git a/test/test.js b/test/test.js
index 581fd18..de0fa65 100644
--- a/test/test.js
+++ b/test/test.js
@@ -72,10 +72,18 @@ describe('hotkey', function () {
setHTML(`
`)
- document.getElementById('textfield').dispatchEvent(new KeyboardEvent('keydown', {key: 'b'}))
+ document.getElementById('textfield').dispatchEvent(new KeyboardEvent('keydown', {bubbles: true, key: 'b'}))
assert.deepEqual(elementsActivated, [])
})
+ it('triggers when user is focused on a file input', function () {
+ setHTML(`
+
+ `)
+ document.getElementById('filefield').dispatchEvent(new KeyboardEvent('keydown', {bubbles: true, key: 'b'}))
+ assert.deepEqual(elementsActivated, ['button1'])
+ })
+
it('handles multiple keys in a hotkey combination', function () {
setHTML('')
document.dispatchEvent(new KeyboardEvent('keydown', {key: 'c', ctrlKey: true}))