focus event not working for select2 search text box?

focus event not working for select2 search text box?

I have a website that uses select2 and jquery 3.3.1. When opening a select2 dropdown, the search-textbox receives the focus so that it's easy to start searching. On mobile devices, this is annoying because it makes the virtual keyboard popup. A workaround I found is the following:
  1.             $(document).ready(function () {
  2.                 window.select2typing = false;

  3.                 $(document).on("focus", ".select2-search__field", function () {
  4.                     if (window.select2typing == false) {
  5.                         $(this).blur();
  6.                     }
  7.                 });

  8.                 $(document).on("click", ".select2-search__field", function () {
  9.                     window.select2typing = true;
  10.                     $(this).focus();
  11.                 });

  12.                 $("select").on("select2:close", function () {
  13.                     window.select2typing = false;
  14.                 });

  15.             });
This works fine in jquery 3.3.1 but when I upgraded tot 3.4.x it stopped working because it seems like the focus event is not working anymore. Is this a known problem? I downgraded tot 3.3.1 again for the time being...