kueblc / LDT

Lightweight in browser syntax highlighting
https://kueblc.github.io/LDT/
159 stars 17 forks source link

Keybinder: Grab input text #12

Closed IngwiePhoenix closed 8 years ago

IngwiePhoenix commented 9 years ago

I would like to be able to react on the entering of special characters. For instance, when the user types in {, I would like to automatically add a closing }.

Previously I had tried using LDT in tandem with BehaveJS...but that did not go well, because Behave.JS "ate" the backspace key; which would prevent api.update() to be called.

IngwiePhoenix commented 8 years ago

I managed to pair Behave.JS and LDT at last. I had to re-assign the keydown and keypress event.

pygy commented 7 years ago

@IngwiePhoenix do you remember exactly what had to be re-assigned? I'd like to pair these libraries as well...

Edit: so, you have to use the BehaveHooks.add() function and call ldt.update() from there:

BehaveHooks.add('keydown', function(data){
  setTimeout(function(){
    ldt.update()
  })
});