Skip to content

Commit 8ab9d67

Browse files
committed
added keyboard.js documentation comments
1 parent 94e499f commit 8ab9d67

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

js/keyboard.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ Key.prototype = {
3535
// const isAlphaNumericKey = function(keyCode) {
3636
// return isAlphabetKey(keyCode) || isNumericKey(keyCode);
3737
// }
38+
39+
// CharMap --------------------------------------------------------------------
40+
/*
41+
CharMap Keys are pair-strings that are related to each other for the editor.
42+
For example:
43+
all enclosing literals are handled diffrently by the editor:
44+
[], {}, (), '', ""
45+
*/
3846
const isCharMapKey = function(char) {
3947
return charMap[char] !== undefined;
4048
}
@@ -50,10 +58,27 @@ const isCharMapValue = function(char) {
5058
const getCharMapValue = function(char) {
5159
return charMap[char];
5260
}
61+
62+
/*
63+
Ignore Keys are keys that need not be handled by the editor.
64+
More like "do nothing when these keys are pressed".
65+
66+
@param {keyCode} code of keyboard key
67+
@return {boolean} true if it is a "IGNORE KEY", otherwise false
68+
*/
5369
const isIgnoreKey = function(keyCode) {
5470
return ignoreKeyList.includes(keyCode);
5571
}
5672

73+
/*
74+
keyToChar accepts keyCode of key on keyboard and
75+
returns the expected character.
76+
It also handles shift and capslock keys.
77+
// TODO handle alt key
78+
79+
@param {keyCode} code of keyboard key
80+
@return expected character mapped to the keyboard
81+
*/
5782
const keyToChar = function(keyCode) {
5883
let char;
5984
if(shiftKey.isPressed() || capsLockKey.isPressed()) {

0 commit comments

Comments
 (0)