Another approach is to assign a tab index to the element that opens the popup menu, which is good accessibility etiquette. The element will then become active (focused) when clicked. Close the popup in an onblur
event handler on that element so that when focus leaves the element, the popup will close.