Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this adds support for both number keys and shift+number keys #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ function emitKey(stream, s) {
key.name = String.fromCharCode(s.charCodeAt(0) + 'a'.charCodeAt(0) - 1);
key.ctrl = true;

} else if (s.length === 1 && s >= '0' && s <= '9') {
// number
key.name = s;

} else if (s.length === 1 && '~!@#$%^&*()_+'.indexOf(s) !== -1) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this only be true for US-ASCII keyboards?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. would you consider merging, to resolve this for US-ASCII keyboards, then we can work on support for non-US-ASCII? No worries either way, I'm happy to try to figure out a more robust solution.

// shift+number
key.name = s;
key.shift = true;

} else if (s.length === 1 && s >= 'a' && s <= 'z') {
// lowercase letter
key.name = s;
Expand Down