Meteor: postpone template.event to run after some func

In my Meteor.startup() I have this func:

window.addEventListener('keyboardHeightWillChange', function(event) {
    Session.set('keyboardHeight', event.keyboardHeight);
});

Later I want to use this Session keyboardHeight in Template.foo.events:

'focus #searchbox' (e, t) {
        $('#search_results').css('height', Session.get('keyboardHeight') - bar);
}

But this event fires before keyboardHeightWillChange. How can I postpone this event to wait for keyboardHeightWillChange to fire first?

Maybe switch this around a little - instead of wiring this up using a focus event in your Template, tell your template what to do in an onRendered callback when the keyboardHeight value changes. Something like:

Template.foo.onRendered(function onRendered() {
  ...
  this.autorun(() => {
    this.$('#search_results').css('height', Session.get('keyboardHeight'));
  });
  ...
});

Thanks, for your answer. Strange, but autorun only starts working on the second keyboardHeightWillChange event fire.