Disable keyboard shortcuts on modal open

When opening a modal with input fields inside, on keydown inside the input (or outside), the palette btns are activated (lasso tool: ‘l’, hand tool: ‘h’, …). How can we disable the shortcuts, when modal is open, and enable it again, when modal is closed.