For anyone looking to use keys to do trigger a click (or anything really!).
In this example, when a user presses the esc button (keycode 27), it triggers a click on a button with the class name close-popup-button
.
<script>
$(document).on('keyup', function(event) {
else if (event.which === 27) {
$('.close-popup-button').click();
}
});
</script>
All key codes can be found here: