How to Position a Context Menu Opened from the Keyboard

A table of orders on a purple gradient with one row focused and a context menu opened at the centre of that row, next to a Shift and F10 key pair

A custom context menu opened with the mouse has an easy job: the contextmenu event carries the pointer’s position, and the menu opens there. The same menu opened from the keyboard, with Shift+F10 or the Menu key, has no pointer to follow. Something still has to decide where it appears, and the obvious answers put it in the wrong place as soon as the page scrolls.

This guide shows which keyboard gestures reach your code at all, how to pick the point when they do not bring one, and how to build a small context menu in plain JavaScript that opens next to the focused element whether that element is fully visible, half scrolled out of its container, or not on the screen at all.

Read More…

Your Mouse Didn't Move, but the Menu Thinks It Did

CoreUI Menu on a purple gradient with the keyboard focus on Export and the Share submenu open under a mouse pointer

Picture a long menu with a scrollbar. A user opens it from the keyboard and walks down the items with the arrow keys, while their mouse just lies on the desk with the pointer somewhere over the panel. The list scrolls, a submenu trigger slides under the resting pointer, and its submenu pops open. One more arrow press, the trigger slides away, and the submenu closes again.

Nobody touched the mouse. The browser decided that the pointer had entered a new element, and the menu believed it. This guide shows why that happens, how to tell a hover the user made from one the browser made up, and how to test it.

Read More…

Focusable Is Not Selectable: A Keyboard Focus Model for Date Grids

CoreUI Calendar showing October and November 2026, weekends unavailable and a Monday-to-Friday range from October 19 to 23 selected

Open almost any date picker, press Tab until you reach the grid, and focus lands on a day. Which day it can land on, and which days the arrow keys can reach, comes down to one small decision that most implementations make without noticing: can an unavailable date receive focus?

The intuitive answer is no. A disabled date is disabled, so you render it as <button disabled>, the browser skips it, and you move on. It looks right in a demo. It stops being right as soon as a real product starts disabling dates: weekends, public holidays, fully booked days, a minimum notice period, a cut-off time.

This post describes the model we use in the CoreUI v6 Calendar, and why: a cell’s focusability depends only on the calendar’s limits. Everything else decides only whether the cell can be selected.

Read More…

How to handle keyboard events in Vue

Keyboard event handling is essential for accessibility, keyboard shortcuts, and improving user experience in web applications. As the creator of CoreUI, I’ve implemented keyboard navigation in countless enterprise applications. Vue provides event listeners with key modifiers to easily capture specific key combinations and keyboard interactions. This approach enables keyboard shortcuts, form navigation, and accessible interfaces without complex event handling code.

Read More…

How to detect Escape key in JavaScript

Detecting the Escape key is essential for implementing intuitive UI interactions like closing modals, canceling operations, and providing exit paths in web applications. As the creator of CoreUI, I’ve implemented Escape key detection in countless modal dialogs and overlay components. The most reliable approach is using the keydown event listener and checking for event.key === 'Escape'. This method provides consistent behavior across all modern browsers and follows accessibility best practices.

Read More…

How to detect Enter key in JavaScript

Detecting the Enter key specifically is crucial for form submissions, search functionality, and creating intuitive user interfaces. As the creator of CoreUI, I’ve implemented Enter key detection in countless form components and interactive elements. The most reliable and modern approach is checking for event.key === 'Enter' within a keydown event listener. This method works consistently across all browsers and provides clear, readable code.

Read More…

How to detect key press in JavaScript

Detecting keyboard input is essential for creating interactive web applications, from form validation to keyboard shortcuts. As the creator of CoreUI, a widely used open-source UI library, I’ve implemented keyboard event handling countless times in production components. From my experience, the most reliable approach is using the keydown event with addEventListener. This method provides consistent behavior across all modern browsers and gives you full control over the keyboard interaction.

Read More…
Subscribe to our newsletter
Get early information about new products, product updates and blog posts.