Use keyboard shortcuts, regardless of the keyboard layout

AI-generated summary

Users discuss enhancing Discourse’s keyboard shortcuts to work seamlessly across different keyboard layouts, particularly Cyrillic. youwiki proposes adding alternative key bindings in keyboard-shortcuts.js.es6 for Cyrillic users (e.g., ‘ы’ for share, ‘д’ for like), noting that current shortcuts require switching to Latin layout. sam raises concerns about character overlap (e.g., Latin ‘a’ vs. Cyrillic ‘а’), but elijah clarifies they are distinct Unicode characters. youwiki provides a visual of the Cyrillic-Latin layout and emphasizes no functional overlap in proposed bindings. Alex_P confirms the issue and notes that some shortcuts (like Ctrl+Ы) already work, but others (e.g., j/k) do not. sam is open to a PR and asks if Gmail/Youtube handle this correctly — Alex_P confirms they do, and suggests using key codes instead of letter characters for broader compatibility, demonstrating via GIF how key codes remain consistent across layouts. Testing is feasible via OS layout switching or on-screen keyboards.

Good afternoon!

To use keyboard shortcuts to the user with different from the Latin keyboard layout, must switch it first. It is not too convenient.

Maybe it makes sense to add bindings to the file app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 for the keys that relevant to Latin keys?

Here is implementation for users with a Cyrillic keyboard:

'№':               {handler: 'goToPost', anonymous: true},
'\\':              {handler: 'toggleSearch', anonymous: true},
'+':               {handler: 'toggleHamburgerMenu', anonymous: true},
',':               {handler: 'showHelpModal', anonymous: true},
'ю':               {click: '.alert.alert-info.clickable', anonymous: true}, // show incoming/updated topics
'и':               {handler: 'toggleBookmark'},
'с':               {handler: 'createTopic'},
'ctrl+а':          {handler: 'showPageSearch', anonymous: true},
'command+а':       {handler: 'showPageSearch', anonymous: true},
'ctrl+з':          {handler: 'printTopic', anonymous: true},
'command+з':       {handler: 'printTopic', anonymous: true},
'в':               {postAction: 'deletePost'},
'у':               {postAction: 'editPost'},
'end':             {handler: 'goToLastPost', anonymous: true},
'command+down':    {handler: 'goToLastPost', anonymous: true},
'а':               {handler: 'toggleBookmarkTopic'},
'п р':             {path: '/', anonymous: true},
'п д':             {path: '/latest', anonymous: true},
'п т':             {path: '/new'},
'п г':             {path: '/unread'},
'п с':             {path: '/categories', anonymous: true},
'п е':             {path: '/top', anonymous: true},
'п и':             {path: '/bookmarks'},
'п з':             {path: '/my/activity'},
'п ь':             {path: '/my/messages'},
'home':            {handler: 'goToFirstPost', anonymous: true},
'command+up':      {handler: 'goToFirstPost', anonymous: true},
'о':               {handler: 'selectDown', anonymous: true},
'л':               {handler: 'selectUp', anonymous: true},
'д':               {click: '.topic-post.selected button.toggle-like'},
'ь ь':             {handler: 'setTrackingToMuted'}, // mark topic as muted
'ь к':             {handler: 'setTrackingToRegular'}, // mark topic as regular
'ь е':             {handler: 'setTrackingToTracking'}, // mark topic as tracking
'ь ц':             {handler: 'setTrackingToWatching'}, // mark topic as watching
'щ':         		 {click: '.topic-list tr.selected a.title', anonymous: true}, // open selected topic
'з':               {handler: 'showCurrentUser'},
'й':               {handler: 'quoteReply'},
'к':               {postAction: 'replyToPost'},
'ы':               {click: '.topic-post.selected a.post-date', anonymous: true}, // share post
'shift+о':         {handler: 'nextSection', anonymous: true},
'shift+л':         {handler: 'prevSection', anonymous: true},
'shift+з':         {handler: 'pinUnpinTopic'},
'shift+к':         {handler: 'replyToTopic'},
'shift+ы':         {click: '#topic-footer-buttons button.share', anonymous: true}, // share topic
'shift+я shift+я': {handler: 'logout'},
'е':               {postAction: 'replyAsNewTopic'},
'г':               {handler: 'goBack', anonymous: true},
'ч к':             {click: '#dismiss-new,#dismiss-new-top,#dismiss-posts,#dismiss-posts-top'}, // dismiss new/posts
'ч е':             {click: '#dismiss-topics,#dismiss-topics-top'} // dismiss topics
4 лайка

My concern here is around the overlapping letters like a and e.

Perhaps a site setting to switch this for communities that use Cyrillic? Which locales do we have now that use this layout?

3 лайка

a and а might look the same, but are different characters: a а

Same with e and е. I expect users of Cyrillic keyboards will get that immediately.

5 лайков

Here are the Cyrillic-Latin keyboard:

I mean here that if at the moment I have Cyrillic layout, then i should switch it (Shift+Alt) to Latin for Discourse keyboard shortcuts using.

I propose to add additional bindings to resolve this issue, for example:

  • for share: 's,ы': {click: '.topic-post.selected a.post-date', anonymous: true}
  • for likes: 'l,д': {click: '.topic-post.selected button.toggle-like'}
    etc. There is no overlapping.
1 лайк

Да, +1

Раздражает, когда в некоторых раскладках ярлыки не работают.

Например, Ctrl+Ы в большинстве приложений работает как Ctrl+S, и даже на Discourse Ctrl+А работает как Ctrl+F. Но другие ярлыки, такие как k и j, здесь в русской раскладке не работают.

1 лайк

Мы открыты к PR, который исправит это, так как в нашей команде нет людей с клавиатурой русской раскладки.

Работает ли Gmail здесь как ожидается?

2 лайка

Да, и YouTube тоже.

Это должно быть легко проверить: вы можете просто добавить другую раскладку в вашу ОС и нажимать те же клавиши, что и обычно. Кроме того, во всех операционных системах есть виртуальные/экранные клавиатуры.


Что касается обходного пути, предложенного в первом сообщении, возможно, было бы лучше использовать коды клавиш вместо букв для каждой нелатинской раскладки? Насколько я понимаю, они одинаковы повсюду.

4 лайка