File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed
java/com/ichi2/anki/ui/windows/reviewer Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,15 @@ globalThis.ankidroid.onTypeAnswerInput = function (event) {
3030 window . location . href = `ankidroid://typeinput/${ encodedValue } ` ;
3131} ;
3232
33+ /**
34+ * @param {KeyboardEvent } event - the onkeydown event of the type answer <input>
35+ */
36+ globalThis . ankidroid . onTypeAnswerKeyDown = function ( event ) {
37+ if ( event . key === "Enter" ) {
38+ window . location . href = `ankidroid://show-answer` ;
39+ }
40+ } ;
41+
3342document . addEventListener ( "focusin" , event => {
3443 window . location . href = `ankidroid://focusin` ;
3544} ) ;
Original file line number Diff line number Diff line change @@ -720,6 +720,7 @@ class ReviewerFragment :
720720 " focusin" -> webviewHasFocus = true
721721 " focusout" -> webviewHasFocus = false
722722 " typeinput" -> url.path?.substring(1 )?.let { viewModel.typedAnswer = it }
723+ " show-answer" -> viewModel.onShowAnswer()
723724 }
724725 true
725726 }
Original file line number Diff line number Diff line change @@ -577,7 +577,7 @@ class ReviewerViewModel(
577577 val repl =
578578 """
579579 <center>
580- <input type="text" id="typeans" oninput="ankidroid.onTypeAnswerInput(event);"
580+ <input type="text" id="typeans" oninput="ankidroid.onTypeAnswerInput(event);" onkeydown="ankidroid.onTypeAnswerKeyDown(event);"
581581 style="font-family: '${typeAnswer.font} '; font-size: ${typeAnswer.fontSize} px;">
582582 </center>
583583 """ .trimIndent()
You can’t perform that action at this time.
0 commit comments