Can we update Anki iOS to focus in reviewer?

@dae any chance we can update the iOS version so that it focuses in reviewer? At the moment I have to tap something on the note and then I can use a keyboard shortcut to trigger JavaScript (i.e. I have JavaScript on my note type that allows me to use “h” to reveal hints and would love to use it the same way we do on desktop). I’ve recently been using the iPad app more often and I had someone email me today asking the same thing and figured I’d bring it up here

Could you provide me with a 1 card apkg to easily test with?

This note type has a few shortcuts - n for revealing the IO occlusions one at a time, , for revealing all of them at once and h for revealing the button hints

I have been searching for a solution for this for months. On desktop it works fine, but for example iPad with magic keyboard I either have to tap on the screen to kinda “activate” the function, or I have to use the trackpad first and click so I can trigger the actions. Same problem here.

Please let me know how you go when the next beta comes out.

Can you ping me here when you’ve released it?

You should have gotten a TestFlight notification? It’s available now in any case.

Seems to be working well now! Thanks!

Any chance you’ll allow for custom shortcuts or at least jkl; for the answer responses?

Custom shortcuts are on the todo list

solved my problem too, thanks!
has using the Βeta version of Anki mobile any possible side effect on desktop? Or is the biggest risk just that there occur problem on mobile, but the database is untouched?

does that include for example toggling the keyboard key “w” with pushing “X” on the controller?

Probably not by injecting keystrokes, but there are other approaches that could be used to trigger custom JavaScript.

The next beta adds some new actions that will call userJs1(), … userJs8(). You can define one or more of those function in your card template, and have them call your existing routines in order to be able to trigger them via a game controller.

2 Likes

How exactly do you change the note type in AnKing to allow for a custom shortcut with “User Action 1-8” on this AnkiMobile Beta? I want to be able to tag a button on my Xbox controller to open the next one by one in a card.

Find the reveal next cloze function in the javascript in the card template, and duplicate it verbatim, but change the name of function to userJs1().

For example, the template I’m using uses the following reveal next cloze function. I just copied the whole thing and pasted it a second time and updated only the top line replacing “revealNext” with “userJs1”

function revealNext() {
	//let flag = 0;
	if(cloze_num<=0)
	{
		flipToBack();
	}
	/*$('.cloze').each(function(){
		if(flag != 0)
			return;
		if($(this).attr("answer") == "off"){
			cloze_toggle($(this));
			flag = 1;
		}
	});*/
	let cloze_len = cloze_objs.length;
	let idx = -1;
	for(let i=cloze_len-1; i>=0; i--)
	{
		if(cloze_objs[i].attr("answer") == "on"){
			idx = i+1;
			break;
		}
	}
	if(idx < cloze_len && idx>=0)
	{
		if(cloze_objs[idx].attr("answer") == "off"){
			cloze_toggle(cloze_objs[idx]);
			return;
		}
	}
	for(let i=0; i<cloze_len; i++)
	{
		if(cloze_objs[i].attr("answer") == "off"){
			cloze_toggle(cloze_objs[i]);
			break;
		}
	}
}

function userJs1() {
	//let flag = 0;
	if(cloze_num<=0)
	{
		flipToBack();
	}
	/*$('.cloze').each(function(){
		if(flag != 0)
			return;
		if($(this).attr("answer") == "off"){
			cloze_toggle($(this));
			flag = 1;
		}
	});*/
	let cloze_len = cloze_objs.length;
	let idx = -1;
	for(let i=cloze_len-1; i>=0; i--)
	{
		if(cloze_objs[i].attr("answer") == "on"){
			idx = i+1;
			break;
		}
	}
	if(idx < cloze_len && idx>=0)
	{
		if(cloze_objs[idx].attr("answer") == "off"){
			cloze_toggle(cloze_objs[idx]);
			return;
		}
	}
	for(let i=0; i<cloze_len; i++)
	{
		if(cloze_objs[i].attr("answer") == "off"){
			cloze_toggle(cloze_objs[i]);
			break;
		}
	}
}

I don’t know what I’m doing, but this worked for me after assigning user action 1 to my gamepad.

Untested, but a cleaner solution might be:

var userJs1 = revealNext;
2 Likes

lol. thanks for the tip!

Also, in the next beta, would it be possible to make it so…

Current behavior: I tap an area assigned to custom js on a card that doesn’t have anything assigned to the custom js in that particular card’s template ➥ pop up warns me “Custom JS function not defined”.

New behavior: I tap an area assigned to custom js on a card that doesn’t have anything assigned ➥ no popup. nothing at all happens. (user will no function isn’t working because nothing happens.)

because otherwise, i’m constantly inadvertently triggering these warnings. THANKS!