function unlistenByKey(key) {
  if (key && key.target) {
    key.target.removeEventListener(key.type, key.listener);
    clear(key);
  }
}
Unregisters event listeners on an event target. Inspired by
https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html

The argument passed to this function is the key returned from
{@link module:ol/events.listen} or {@link module:ol/events.listenOnce}.

@param {EventsKey} key The key.