XF 2.3 Disable or suppress xenforo shortcuts?

Robert9

Well-known member
Licensed customer
We need to use A–Z keys inside a popup/menu for navigation (jumping to items by first letter).

The problem is that XenForo’s global shortcuts still fire — for example pressing “m” also opens the user menu in the background.

What is the correct way to prevent global keyboard shortcuts from triggering while a popup/menu is active?

Is there an official method to temporarily disable or suppress those shortcuts?
 
The simplest way to handle this is to stop the keydown event from bubbling up to the document level where XenForo's global shortcuts listen.

Add a keydown listener on your popup element that catches letter keys before they reach the global handler:

yourPopupElement.addEventListener('keydown', function(e) {
if (e.key.length === 1 && e.key.match(/[a-z]/i)) {
e.stopPropagation();
}
});

This blocks A-Z from reaching XenForo's shortcut system while your popup is open, but still lets Escape, Tab, and arrow keys work normally.

If you're building a proper XF add-on with XF.Element, you could also look into temporarily detaching the shortcut handlers when your popup opens and reattaching on close — but honestly the stopPropagation approach is cleaner and won't break if XenForo changes their shortcut internals in a future update.
 
Back
Top Bottom