js detect cmd+s
// To detect Cmd key pressed, check Event.key === 'Meta'
document.querySelectorAll('#form').forEach(form => {
let meta_pressed = false;
form.addEventListener('keydown', e => {
if ( e.key === 'Meta' ) {
meta_pressed = true;
} else if ( e.key === 's' ) {
// Keep the browser from running its own
// Cmd+S (Save Page As...) function
e.preventDefault();
form.submit();
}
});
form.addEventListener('keyup', e => {
if ( e.key === 'Meta' ) {
meta_pressed = false;
}
});
});
Also in JavaScript:
- for array javascript
- archiver compressed file in nodejs
- img src in react js
- javascript add input
- react data attributes event
- read file node
- javascript array of objects access properties
- how to modify an array
- set up background process in express app
- how to get a particular line from a file in nodejs
- No matching version found for swagger-jsdoc@^6.0.0.
- calculate time difference in javascript
- js show span for 5 seconds
- how to identify specific letter from a string in javascript
- from json timestamp to date python
- owl responsive
- start angular app server
- iframe video speed
- open pdf in browser javascript
- what is nodes and hubs in selenium grid
- password validation with regular expression in javascript
- jquery on scroll
- build a trivia and answer javascript
- how to check if browser is firefox in javascript