How can I know macOS mand keys in JavaScript.
Need to know left and right mand keys. I know key codes of these both but I don't know how to separate from other keys.
How can I know macOS mand keys in JavaScript.
Need to know left and right mand keys. I know key codes of these both but I don't know how to separate from other keys.
Share Improve this question edited Jan 31, 2017 at 6:12 tadman 212k23 gold badges236 silver badges265 bronze badges asked Jan 31, 2017 at 5:03 Shanmugaraja_KShanmugaraja_K 2,4323 gold badges15 silver badges26 bronze badges 3- Possible duplicate of jQuery key code for mand key – Alexander Elgin Commented Jan 31, 2017 at 5:54
- See stackoverflow./a/3834210/92701 – Alexander Elgin Commented Jan 31, 2017 at 5:55
- MAC refers to something very specific to do with networking. "Macintosh" or "Mac" is a trademark of Apple. – tadman Commented Jan 31, 2017 at 6:13
2 Answers
Reset to default 5You could look on keydown/keyup and record when a key is pressed based on event.keyCode
.
Or as Alexander pointed out, you can also use:
event.metaKey
https://developer.mozilla/en-US/docs/Web/API/MouseEvent/metaKey
There are some libraries which can help you out as these keys are browser dependent
See the snippet below
$(window).keydown(function (e){
if (e.metaKey) {
alert('meta key is pressed');
}
});
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>