As long as you use HTTPS and make sure you set redirect uris correctly it's secure. The authorization code has a short lifespan so there's very low chance that someone could retrieve it from the browser history. Further the redirect uris prevent other applications from sniffing it.
I don't see how what you are proposing would be any more secure. You still have to transfer the token to the HTML5 application. So you've used moved the problem from the interaction between Keycloak to a custom implementation on your end.