Please, consider the following code.
Question
There are no particular benefits in setting event listeners in HTML. Moreover it is considered harmful, e.g. CSP bans it https://developers.google.com/web/fundamentals/security/csp#inline_code_is_considered_harmful