The question is pretty simple. I couldn\'t find many links regarding this issue, and the ones I found didn\'t seemed to avoid the real question. My application must handle t
Credit belongs to the original responders, just adding a ready-to-use code sample for global back-/forward-button detection in case it helps anyone else (JDK 1.8)
if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled() && MouseInfo.getNumberOfButtons() > 3) {
Toolkit.getDefaultToolkit().addAWTEventListener(event -> {
if (event instanceof MouseEvent) {
MouseEvent mouseEvent = (MouseEvent) event;
if (mouseEvent.getID() == MouseEvent.MOUSE_RELEASED && mouseEvent.getButton() > 3) {
if (mouseEvent.getButton() == 4) {
// back
} else if (mouseEvent.getButton() == 5) {
// forward
}
}
}
}, AWTEvent.MOUSE_EVENT_MASK);
}