JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<input type='checkbox' id='testBox' />
</body>
JavaScript
var body = $(document.body);
var input = $('#testBox');
body.on('click', function(e) {
// e.stopPropagation();
console.log('body shift', e.shiftKey);
});
input.on('click', function(e) {
e.stopPropagation();
console.log('input shift:', e.shiftKey, 'checked: ', input.is(':checked'));
});
var clickEvent = new MouseEvent('click', {
'view': window,
'bubbles': true,
'cancelable': true,
'shiftKey': true
});
body[0].dispatchEvent(clickEvent);
input[0].dispatchEvent(clickEvent);
console.log('After, input checked: ', input.is(':checked'));