JS
Use window event resize:
window.addEventListener('resize', resizeCanvas, false);
You should use document.documentElement.clientHeight/Width because thay take scrollbar into consideration when window.innerHeight/Width do not.
By the way you can use this:
let scrollHeight = window.innerWidth && document.documentElement.clientWidth ?
Math.min(window.innerWidth, document.documentElement.clientWidth) :
window.innerWidth ||
document.documentElement.clientWidth ||
document.getElementsByTagName('body')[0].clientWidth;
Or this:
let scrollHeight = Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight );
You can just replace width and height words with each other in the above example
CSS
* { margin:0; padding:0; } /* to remove the top and left whitespace */
html, body { width:100%; height:100%; } /* just to be sure these are full screen*/
canvas { display:block; } /* To remove the scrollbars */