I’d suggest you try using Robot. Use the code below:
Alert alert = driver.switchTo().alert();
Robot a = new Robot();
a.keyPress(KeyEvent.VK_ENTER);
There is a huge difference in terms of how these tools work. Selenium uses the WebDriver API and sends commands to a browser to perform actions (through the "JSON wire protocol").
Java AWT Robot uses native system events to control the mouse and keyboard.
If you are doing browser automation, ideally, you don't ever use things like Robot since usually, the functionality provided by selenium is more than enough. Though there are cases when there is a browser or native OS popup opened, for example, to upload/download a file - this is something that can also be solved with Robot.