Anki-android: [Feature request] add shortcuts for ChromeOS and other devices with keyboards

Created on 12 Feb 2019  路  17Comments  路  Source: ankidroid/Anki-Android

As you might know, ChromeOS has an option to install Android apps on its OS. This works quite well with AnkiDroid, even going as far as providing the user with some basic shortcuts. For example, I'm able to use the 篓3篓 key to press answer button 3. Unfortunately, there aren't many of these useful shortcuts. As a starter, these shortcuts would really help me create cards more quickly:

  • tab: go to next text insertion prompt. Switch from question to answer prompt during card creation for example
  • ctrl+enter: save new card

Feel free to add other shortcut proposals in this issue

Good First Issue! Help Wanted Waiting For Feedback

All 17 comments

I haven't used Java much, but this seems like the place where keyboard shortcuts for the card viewer are implemented. Maybe this can serve as an example for someone who wants to implement this?

https://github.com/ankidroid/Anki-Android/blob/c6f2577db6e9d5380db118392e1f1ba780d6cf5f/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.java#L260

I'm not against this in general but it's my understanding that the whole idea of "Chrome Apps" is going away and is basically only available / still alive as a stopgap while ChromeBooks all get the native power to run Android apps. Adding shortcuts and keyboard/mouse accessibility for navigation etc would help other formats (like Android TV). Which is just to say that if you begin building this style of workflow into your review routine you may be disappointed shortly when it's no longer possible unless my read of the Chrome Apps situation is wrong...

I'm not sure whether I understand your comment correctly, @mikehardy. I am currently running the Ankidroid .apk on my Chromebook. The problem is that it doesn't support all the keyboard shortcuts that I'd like. I'm not using some sort of Anki chrome extension.

Ah excellent! I misunderstood your original comment sorry. This should be fine then and has a future...

@mvanaltvorst I am unsure what the current state of the art is with regard to distribution of apps on Chromebooks. Are you able to use the Play Store now and install the AnkiDroid .apk from there, or do you have to install (and update) from the Chrome store? 2.9 is out now and I could update it on the Chrome store - it has many more keyboard shortcuts I believe? - but it may be that Chromebook users are all migrating to using native Android APKs - I'm not sure

Any information appreciated

I'm not a chromebook user, but I use a bluetooth keyboard with the 2.9 alphas on my phone. I appreciate the recent efforts to integrate some of the desktop shortcuts that are available:
'b' for the card browser
'a' for the add card screen

Regarding @mvanaltvorst original post; I'm currently on 2.10alpha9 and Ctrl + Enter works as expected when adding a cards. Tab (and Shift+Tab) works with selecting an input field, but every other press of the Tab will select the "clipboard menu" that is to the right of each field. From what I can tell, there's no visual indication that this menu is selected but if enter is pressed, then the menu will open with "Add image, Add audio clip, ...". Perhaps a highlight indication is needed to show when this menu is selected?

At this point, the pressing Tab twice is engrained in my muscle memory when adding cards in AnkiDroid, but I recently found that Ctrl + down arrow / up arrow will allow you to move to the next / previous field, even with fields containing newline chars. This behviour might be specific to my version of Android or BT keyboard, but maybe the shortcuts I've shared will help someone.

I would like to see AnkiDroid with more desktop shortcuts as well:
"y" to start a sync on the deck screen
"ctrl + shift + n" to Manage note types
etc.

On the "Edit cards"/"Card types" I think it would be really useful to have:
"ctrl + p" to preview the current card type

Thanks for the feedback! The last PR that added things was from @werkn - you can see the general style here, it appears to be an onKeyUp() override in the code for the activity you want shortcuts in, then you switch on the keypresses you want to tie to the actions you want and that appears to be that. https://github.com/ankidroid/Anki-Android/pull/4815/files

@werkn here, I would suggest if anyone wants to continue to develop keyboard shortcuts that it would make sense to integrate maybe a JSON file like keybindings.json and then allow that to be customized per platform. I've done something similar with my own codebase for Anki.

That being said the functionality requested above would be fairly trivial to implement as the app sits now without such a system.

I just remember last time I implemented changes it felt a bit messy and I feel the structure of a seperate JSON config instead of hard coding bindings would make sense with the app moving forward for maintainability and usability.

interesting idea - is there any traction on the Anki / python side to have that formalized / integrated with the main codebase there? (restated: is there something existing in the ecosystem we can/should conform to? or any official statements on the same?)

I don't have an answer to @mikehardy's question, but I pose one as well:
If there is a keybindings.json, could we have it (along with other AnkiDroid settings such as such as nightmode, gestures, and fonts) sync with other devices running AnkiDroid?

Recently I was poking around my collection.anki2 in an attempt to familiarize myself with the Anki database structure. I noticed my collection had an extra table, "android_metadata". I assume Ankidroid created this rather than Anki desktop. Is this where we could store a keybindings.json, as well as other AnkiDroid settings to have them sync? Currently this table has a single column called "locale"

if you want it to sync it would have to be in the global conf - you can check the schema wiki article in this repo to see what's in there. It's basically a big JSON bag that sync with your collection and we can use it for about anything

would not be user visible though unfortunately :-), unless they were comfortable both opening a sqlite database and then editing JSON inside it. tradeoffs

Hello 馃憢, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like _still searching for solutions_ and if you found one, please open a pull request! You have 7 days until this gets closed automatically

Hello 馃憢, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like _still searching for solutions_ and if you found one, please open a pull request! You have 7 days until this gets closed automatically

Missed:

I would like to see AnkiDroid with more desktop shortcuts as well:
"y" to start a sync on the deck screen
"ctrl + shift + n" to Manage note types
etc.

On the "Edit cards"/"Card types" I think it would be really useful to have:
"ctrl + p" to preview the current card type

re-tagging issue for release-2.14 for the remaining couple of shortcuts

Was this page helpful?
0 / 5 - 0 ratings

Related issues

david-allison-1 picture david-allison-1  路  4Comments

hanpingchinese picture hanpingchinese  路  5Comments

david-allison-1 picture david-allison-1  路  5Comments

mikehardy picture mikehardy  路  5Comments

mashinbaz1 picture mashinbaz1  路  6Comments