Working with 4.3, in plugins/dialog/plugin.js
For all input fields in a dialog, CKEditor listens for "keyup". If it's an enter, it assume the user wants to close out the dialog.
I'm working on a bug in a Drupal module "ckeditor_link" (https://drupal.org/node/1991076). This module creates an autocomplete text field in the Link dialog (from CKEditor), so that when you search for something, it presents a list of potential items that you can use as the link. Typically, a user could use the arrow keys to cycle through them, then press enter to select them. The code where it's added is here (line 80). That function "initAutocomplete" is called and adds a keyup handler that listens for the Enter key, just like CKEditor does.
However, CKEditor ALSO adds an event listener on the same element, for the same event, but does it before the above one is added by the Drupal module (plugins/dialogui/plugin.js, around line 225). It can't perform its function properly: CKEditor closes out the dialog and uses whatever was in the input field at the time it was closed. When Drupal's handler runs, it's already too late. Event listeners are executed in the order they are attached.
What I'm asking is if there is a better place to call that Drupal function that adds the event listener so that it executes before CKEditor's? I took a look here but doesn't look like there are any more appropriate places to do this. Is this just not possible?
What about removing the CKEditor event listner and then re-attaching it manually? I took a look here, and while there are ways to remove an event listner, there's no way to obtain it and re-attach it.
Please, suggestions welcome, been pulling my hair out over this!