Skip to content

Commit

Permalink
chore: migrate src/USKeyboardLayout to typescript
Browse files Browse the repository at this point in the history
Don't think we need to expose the interface type for the keycodes so
I've left it local for now.
  • Loading branch information
jackfranklin committed Apr 20, 2020
1 parent e7a32a8 commit 37a9467
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Input.js
Expand Up @@ -15,7 +15,7 @@
*/

const {assert} = require('./helper');
const keyDefinitions = require('./USKeyboardLayout');
const {keyDefinitions} = require('./USKeyboardLayout');

/**
* @typedef {Object} KeyDescription
Expand Down
28 changes: 12 additions & 16 deletions src/USKeyboardLayout.js → src/USKeyboardLayout.ts
Expand Up @@ -14,22 +14,18 @@
* limitations under the License.
*/

/**
* @typedef {Object} KeyDefinition
* @property {number=} keyCode
* @property {number=} shiftKeyCode
* @property {string=} key
* @property {string=} shiftKey
* @property {string=} code
* @property {string=} text
* @property {string=} shiftText
* @property {number=} location
*/
interface KeyDefinition {
keyCode?: number;
shiftKeyCode?: number;
key?: string;
shiftKey?: string;
code?: string;
text?: string;
shiftText?: string;
location?: number;
}

/**
* @type {Object<string, KeyDefinition>}
*/
module.exports = {
export const keyDefinitions: Readonly<Record<string, KeyDefinition>> = {
'0': {'keyCode': 48, 'key': '0', 'code': 'Digit0'},
'1': {'keyCode': 49, 'key': '1', 'code': 'Digit1'},
'2': {'keyCode': 50, 'key': '2', 'code': 'Digit2'},
Expand Down Expand Up @@ -285,4 +281,4 @@ module.exports = {
'EndCall': {'keyCode': 95, 'key': 'EndCall', 'code': 'EndCall', 'location': 4},
'VolumeDown': {'keyCode': 182, 'key': 'VolumeDown', 'code': 'VolumeDown', 'location': 4},
'VolumeUp': {'keyCode': 183, 'key': 'VolumeUp', 'code': 'VolumeUp', 'location': 4},
};
};

0 comments on commit 37a9467

Please sign in to comment.