Keshav Gautam
Jun 4, 2021

--

keyboard event functionality

/****

*

*@purpose — Prepose for using this event here is that we can trigger keyboard event functionality in multiple location.

*

* **********/

document.addEventListener(‘keydown’, function (event) {

// arrow down

if (event.which === 40) {

}

// arrow up

if (event.which === 38) {

}

// enter

if (event.which === 13 && !event.ctrlKey && !event.metaKey) {

}

// escape

if (event.which === 27) {

}

// tab

if (event.which === 9) {

}

// ctrlKey + enter

if (event.which === 13 && event.ctrlKey) {

}

// ctrlKey + enter

if (event.which === 13 && event.metaKey) {

}

// shiftKey + enter

if (event.which === 13 && event.shiftKey) {

}

// shiftKey + enter

if (event.which === 13 && !event.shiftKey) {

}

});

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Keshav Gautam
Keshav Gautam

No responses yet

Write a response