diff --git a/src/index.ts b/src/index.ts index 5ea3249..914759a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -120,6 +120,16 @@ function keyboardBindings(event: KeyboardEvent, combobox: Combobox) { combobox.navigate(-1) event.preventDefault() break + case 'Home': + combobox.clearSelection() + combobox.navigate(1) + event.preventDefault() + break + case 'End': + combobox.clearSelection() + combobox.navigate(-1) + event.preventDefault() + break case 'n': if (ctrlBindings && event.ctrlKey) { combobox.navigate(1) diff --git a/test/test.js b/test/test.js index 0e474c5..91e3549 100644 --- a/test/test.js +++ b/test/test.js @@ -138,6 +138,14 @@ describe('combobox-nav', function() { assert.equal(options[5].getAttribute('aria-selected'), 'true') assert.equal(input.getAttribute('aria-activedescendant'), 'link') + press(input, 'Home') + assert.equal(options[0].getAttribute('aria-selected'), 'true') + assert.equal(input.getAttribute('aria-activedescendant'), 'baymax') + + press(input, 'End') + assert.equal(options[5].getAttribute('aria-selected'), 'true') + assert.equal(input.getAttribute('aria-activedescendant'), 'link') + press(input, 'Enter') assert.equal(expectedTargets.length, 2) assert.equal(expectedTargets[0], 'hubot')