var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope, $timeout) {
/**
* 39 (right arrow)
* 80 (p)
*/
var map = {39: false, 80: false};
$scope.onKeyUp = function(event){
if (map[39] && map[80]) {
$scope.data.message1 = "P + RIGHT pressed!";
$timeout(function(){
$scope.data.message1 = '';
}, 1000);
}
if (event.shiftKey && map[39] && map[80]) {
$scope.data.message2 = "SHIFT + P + RIGHT pressed!";
$timeout(function(){
$scope.data.message2 = '';
}, 1000);
}
var keyCode = getKeyboardEventCode(event);
if (keyCode in map) {
clearKeyCode(keyCode);
}
};
$scope.onKeyDown = function(event){
var keyCode = getKeyboardEventCode(event);
if (keyCode in map) {
map[keyCode] = true;
}
}
var getKeyboardEventCode = function (event) {
return parseInt((window.event ? event.keyCode : event.which));
};
function clearKeyCode(code){
map[code] = false;
}
$scope.data = {
'message1': '',
'message2': ''
};
});
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>Jordie - NGPlunk</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.3.x" src="https://code.angularjs.org/1.2.3/angular.js" data-semver="1.2.3"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl" ng-keyup="onKeyUp($event)" ng-keydown="onKeyDown($event)">
<p>
Working case(p+right):<br/>
<div style="color: red">{{ data.message1}}</div>
</p>
<p>
Not working case(p+right+shift):<br/>
<div style="color: red">{{ data.message2}}</div>
</p>
<br/><br/><br/><br/><br/><br/>
The problem is to detect SHIFT + RIGHT ARROW + P<br/>
Only RIGHT ARROW + P is working well but when the shift comes into game something brakes
</body>
</html>
/* Put your css in here */
.panel {
margin: 0 auto;
width: 60%;
padding: 2em;
margin-top:2em;
border: 1px solid #d8d8d8;
border-radius: 2px;
box-shadow: 1px 1px 3px #e8e8e8;
}
input[type="text"] {
width: 160px;
max-width: 65%;
outline: 0;
padding: .75em;
font-size: 14px;
color: #888;
background: #f0f0f0;
border: 1px solid #f0f0f0;
border-radius: 4px;
transition: all 400ms linear;
}
span.searchClear {
color: #3ae;
width: 100%;
margin-left: .25em;
}
span.searchClear:hover {
color: #3ae;
}
button.options {
max-width: 30%;
float:right;
padding: .75em;
font-size: 14px;
color: #333;
background: #e8e8e8;
border: none;
border-radius: 4px;
}
button.options:hover, button.active {
background: #B10004;
color: #e8e8e8;
box-shadow: 1px 1px #444;
text-shadow: -1px 0px #444;
}
button.options:focus {
outline:0;
}
button.options:click {
transform: ;
}
input[type="text"]:focus, input[type="text"]:active, input[type="text"]:hover {
width: 400px;
outline: 0;
opacity: 1;
color: #888;
background: #fff;
border: 1px solid #ddd;
}
input[type="checkbox"] {
display:none;
}
.showOptions {
display:flex;
margin:0;
padding: 0;
border: none;
width: 100%;
margin-top:1em;
background: none;
}
fieldset {
border: none;
padding: 1em .25em 0 0;
}
fieldset ul {
display: flex;
padding-left: 0;
margin: auto;
flex-flow: row wrap;
}
fieldset ul li {
display:inline-flex;
list-style: none;
padding: 0;
margin: 3px;
font-size: 12px;
}
fieldset ul li input[type="checkbox"] {
display:none;
}
fieldset ul li > label {
background: #EFEFEF;
padding: .25em .75em;
border-radius: 14px;
border: 1px solid #ccc;
}
fieldset label:hover, label:active, label:checked, label.filterActive {
background: #CCC;
color: #444;
}
span.terms {
font-style:italic;
color: #B10004;
}
.search-query {
margin-top: 1em;
}