```js

var checkboxes = document.querySelectorAll('input[type=checkbox]');

function func() {
    checkboxes[1].checked = true;
}

for(var i = 0; i < checkboxes.length; i++) {
     checkboxes[i].addEventListener("click", function(i) {
         console.log('cat')
  });
}

```

```html

<input type="checkbox"/>
<input type="checkbox"/>
<input type="checkbox"/>

<button onclick = 'func()'>PRESS</button>

```

How do you get an event listener to respond when a checkbox is being checked by ulterior means, in my example by a button that calls a function that checks a checkbox. The event listener doesn't respond in this situation, only when I directly check a checkbox. Thanks.