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

Revamp handling of multiple key press #545

Merged
merged 4 commits into from
May 4, 2017

Conversation

LeoLamCY
Copy link
Contributor

@LeoLamCY LeoLamCY commented May 3, 2017

LeoLamCY added 4 commits May 3, 2017 00:29
- use keyCodes instead of strings to detect keys
- delete key from keyPressed array on key up
- fix BoostIO#540
-check if number of keys pressed is the same as number of keys in a
shortcut key combo before matching to avoid incorrect detection
@asmsuechan
Copy link
Contributor

Hi, @LeoLamCY! Thank you for this PR! I'd like to ask you a question. Why do you think numbers is better than string in keyCodes? I think a string is readable.

@LeoLamCY
Copy link
Contributor Author

LeoLamCY commented May 3, 2017

please refer to #540
If key codes are used, that bug will not occur when user try to input something that combines the shift key because for example in key codes, the key : is handled as shift + ; (16, 186) instead of being treated as :. So when user releases shift before ;, both key codes are removed from keyPressed properly.
While previously when Strings are used, shift + ; is pushed into keyPressed as {Shift: true, :: true} so when user releases shift before releasing ;, then shift and ; would become false in keyPressed but : would remain true, resulting the bug in #540

Strings are definitely more readable, I would prefer strings too if you could find another solution to the bug in #540

edit: keyPressed should become {Shift: true, :: true} instead of {Shift: true, ;: true, :: true}

@asmsuechan
Copy link
Contributor

asmsuechan commented May 3, 2017

Oh, I understand. The keyboard difference between US and others makes this issue difficult. I'm using JP keyboard. But no worry, it's my mistake. We should implement shortcuts in US keyboard.

Thank you so much for informing me!

BTW, have you used Ctrl + : shortcut? Actually, I've never used it. So I'm contemplating to delete it.

@LeoLamCY
Copy link
Contributor Author

LeoLamCY commented May 3, 2017

I don't use it personally but I think it doesn't hurt to have a few keyboard shortcuts in the program. Some people might use them, you never know :)
I would rather the shortcut be ctrl + b for bold though, don't even need to hit shift then.

@asmsuechan
Copy link
Contributor

Yes, exactly true...! Umm, Ctrl + B has a conflict problem with vim key-bind. I know it's nonsense from who doesn't use vim key-bind.

@LeoLamCY
Copy link
Contributor Author

LeoLamCY commented May 3, 2017

By the way, is it really caused by the difference between US and JP keyboards?
I believe it is caused by the shift key being released early causing keyPressed to have incorrect values.

  • hit shift + ; will result in {Shift: true, ::true}
  • release shift first while still holding ; will result in {Shift: false, ::true, ;:true}
  • release ; now will result in {Shift: false, ::true, ;:false}
  • : remains true in keyPressed even though all keys are now released, which causes the bug

@asmsuechan
Copy link
Contributor

In JP keyboard, : doesn't use Shift. Just { 'Ctrl': true, ':' true}.

@LeoLamCY
Copy link
Contributor Author

LeoLamCY commented May 3, 2017

Oh ok, good to know :)

@justin-calleja
Copy link

justin-calleja commented May 3, 2017

@LeoLamCY @asmsuechan ... ye please don't use ctrl + b it's not just for vim mode. That key combo goes back (like hitting arrow left) in normal mode (it's an Emacs keybinding... or whatever they're called there - and it's probably the default in your terminal program too).

As a side note, in vim ports across editors, being in insert mode also allows the use of these emacs shortcuts allowing one to stay in insert mode to do minor movements while still keeping your hands in home position (and without going back to normal mode). i.e. vim mode or not... these shortcuts are used across many editors and are likely to be ingrained in some ppl's muscle memory.

For the record, I don't personally use ctrl + :.

Also, @asmsuechan - you had an issue open about a "dot config" file for Boostnote (which I can't seem to find now). That's a great idea and would probably be the ideal place to map these keyboard bindings - so users can change according to personal prefs.

@asmsuechan
Copy link
Contributor

Hi, @justin-calleja! I got it. .boostnoterc will support to change key-bind in our future 🌟 I try to implement it as soon as possible 🙇

Copy link
Contributor

@asmsuechan asmsuechan left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Thanks for good PR 😄

@asmsuechan asmsuechan merged commit efd80d5 into BoostIO:master May 4, 2017
@kohei-takata kohei-takata mentioned this pull request Jun 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shift / ctrl key introducing asterisks
5 participants