It's doable but you will invite several challenges that in my opinion is simply not worth it.
Example of this:
var ctx = c.getContext("2d"), rect = c.getBoundingClientRect(), isDown = false;
c.width = rect.width;
c.height = rect.height;
// canvas interaction when no divs are in the way
window.onmouseup = window.onmousedown = function(e) {isDown = e.type === "mousedown"};
window.onmousemove = function(e) {
if (isDown) ctx.fillRect(e.clientX, e.clientY, 2, 2);
};
#c {
position:fixed;
left:0;
top:0;
width:100vw;
height:100vh;
pointer-events:none;
}
div {
padding:10px;
border:1px solid #999;
width:200px;
margin-bottom:9px;
}
<div>Hello</div>
<div>There</div>
<canvas id=c></canvas>
As you can see, sure, we can interact and select divs below the canvas, but we are still drawing to the canvas and so forth.
If I may suggest a different approach, it would be to have a modus switch so that when you activate interactive mode using a switch/button in the UI, only interaction with canvas is allowed, and of course, vica versa when mode is switched off.
The mode button could be attached to a hotkey, middle mouse-button and so forth.
var ctx = c.getContext("2d"), rect = c.getBoundingClientRect(), isDown = false;
var drawMode = false;
c.width = rect.width;
c.height = rect.height;
window.onmouseup = c.onmousedown = function(e) {isDown = e.type === "mousedown"};
// only draw if we are in interactive mode
c.onmousemove = function(e) {
if (drawMode && isDown) ctx.fillRect(e.clientX, e.clientY, 2, 2);
};
// toggle mode
document.querySelector("button").onclick = function() {
this.classList.toggle("selected");
c.classList.toggle("active");
drawMode = !drawMode;
};
#c {
position:fixed;
left:0;
top:0;
width:100vw;
height:100vh;
pointer-events:none;
}
#c.active {
pointer-events:auto;
}
div {
padding:10px;
border:1px solid #999;
width:200px;
margin-bottom:9px;
}
button {
position:fixed;
right:7px;
top:7px;
opacity:0.5;
transition:opacity 0.2s;
background:#9f9;
border:1px solid #000;
padding:7px;
}
button:hover {opacity:1}
button.selected {background:#fc0}
<div>Hello</div>
<div>There</div>
<canvas id=c></canvas>
<button>Interactive mode</button>
<p>Click button in upper right corner to activate interactive drawing on canvas</p>