Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body onkeydown="onKeyDown(event)" onkeyup="onKeyUp(event)">
</body>
</html>
 
var isCtrlPressed = false;
function onKeyDown(event) {
    if (event.keyCode == 17) { // Control got pressed
        isCtrlPressed = true;
    }
    if (event.keyCode == 83) { // "s" got pressed
        // if control is pressed too execute some code
        if (isCtrlPressed) {
            // Your code here
            alert("Ctrl+s pressed");
        }
    }
}
function onKeyUp(event) {
    if (event.keyCode == 17) { // Control got pressed
        isCtrlPressed = false;
    }
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers