A Pen by Shaker Hamdi on CodePen.
Created
August 13, 2019 12:04
-
-
Save Alujjdnd/32c2815f2ada1249d34d379582d835bf to your computer and use it in GitHub Desktop.
Virtual Math Keyboard with MathQuill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>Type math here: <span id="math-field"></span></p> | |
<div id="keyboard"> | |
<div class="btn-group" role="group" aria-label="math functions"> | |
<button type="button" class="btn btn-default" onClick='input("\\sqrt")'>√</button> | |
<button type="button" class="btn btn-default" onClick= 'input("\\sin")'>sin</button> | |
<button type="button" class="btn btn-default" onClick='input("\\cos")'>cos</button> | |
<button type="button" class="btn btn-default" onClick='input("\\tan")'>tan</button> | |
<button type="button" class="btn btn-default" onClick='input("/")'>/</button> | |
<button type="button" class="btn btn-default" onClick='input("\Pi")'>Pi</button> | |
<button type="button" class="btn btn-default" onClick='input("\dagger")'>Dagger</button> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mathFieldSpan = document.getElementById('math-field'); | |
var MQ = MathQuill.getInterface(2); | |
var mathField = MQ.MathField(mathFieldSpan, { | |
spaceBehavesLikeTab: true, | |
handlers: { | |
edit: function() { | |
mathField.focus(); | |
} | |
} | |
}); | |
function input(str) { | |
mathField.cmd(str); | |
mathField.focus(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> | |
<script src="http://mathquill.com/lib/mathquill.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathquill/0.10.1/mathquill.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p { | |
margin-top: 40px; | |
} | |
#math-field { | |
width: 500px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="http://mathquill.com/lib/mathquill.css" rel="stylesheet" /> | |
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css" rel="stylesheet" /> | |
<link href="https://cdnjs.cloudflare.com/ajax/libs/mathquill/0.10.1/mathquill.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment