Skip to content

Instantly share code, notes, and snippets.

@ThomasCrevoisier
Created September 28, 2015 11:57
Show Gist options
  • Save ThomasCrevoisier/b23f82cd6a4561ce0a44 to your computer and use it in GitHub Desktop.
Save ThomasCrevoisier/b23f82cd6a4561ce0a44 to your computer and use it in GitHub Desktop.
String evaluation on ctrl+enter
var keypressed = Bacon.fromEvent(document.getElementById('text-editor'), 'keypress');
var evaluatedString = keypressed
.filter(function (event) { return event.ctrlKey && event.charCode === 10; })
.map(function (event) { return getSelection(event.target.value, event.target.selectionStart, event.target.selectionEnd); })
.filter(function (value) { return !!value.trim(); }).log();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment