Help Me Edit This Script for a Type in Answer Text Box?

yoyoyoyoooo's Avatar

yoyoyoyoooo

28 Sep, 2019 05:32 PM

I'm trying to find a way to put a multi-line answer box into my cards so I can type notes into them as I work through the cards and then check my answer.

I found the following script (below) which lets me put a multi-line text box into the cards. The only problems I have with it are that (1) it doesn't keep the text I've written when I go to the back of cloze deletion cards and (2) there's no shortcut for me to advance once I'm done writing (I have to manually click away from the box first).

Does anyone know of a way to edit this script so (1) it keeps the text I've written when I go to the back of the cloze card and (2) it has a shortcut like ctrl + enter to advance to the back of the card? Thank you!!

Code:

<script>
  var theInput = document.getElementById('typeans');
  if (theInput && theInput.nodeName == "INPUT") {
    var newArea = document.createElement('textarea');
    newArea.value = theInput.value;
    newArea.style = theInput.style;
    newArea.onkeypress = function() { this.value = this.value.replace(/ *\n/gi, " \n"); };
    newArea.id = theInput.id;
    theInput.parentNode.replaceChild(newArea, theInput);
  }
</script>

Comments are closed, but you can start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac