On my sites, I'm currently using this ? chain which disables autocomplete on the address fields (in Chrome) and prevents the return key:
jQuery('form#post input[id^=address][type=text]').attr('autocomplete', 'new-password').keypress(function(e) {
if (e.which == 13) return false;
});
A few other options for this...
1️⃣
This ? disables submission anytime the Enter/Return key is pressed inside any form element (including Google Maps, but also on any other element):
jQuery('.wp-admin.post-type-CUSTOMPOST form#post').keypress(function(e) {
if (e.which == 13) return false;
});
Here ? I'm targeting only the pages for my custom post type called CUSTOMPOST
(so change that to your post type) or else just use jQuery('form#post')....
to attach this to all edit post screens.
2️⃣
And for completeness... there is also Google Maps' prescribed way of adding event listeners: https://developers.google.com/maps/documentation/javascript/events#DomEvents ?
google.maps.event.addDomListener(jQuery('#idOfTextInput')[0], 'keydown', function(e) {
if (e.keyCode === 13) return false;
});
Since we're in WordPress, I'm still using jQuery here ? you could easily write it with plain JS if needed. But since I'm still using jQuery here, I don't see the reason for using the Google Maps method.