chjj / blessed

A high-level terminal interface library for node.js.
Other
11.27k stars 533 forks source link

List 'select' event fires twice using enter key #90

Open thillerson opened 9 years ago

thillerson commented 9 years ago

For some reason the 'select' event, hitting enter on an item in a List, fires twice.

On a Mac, I've tested in iTerm2 and Terminal.app using zshell. Compiled and run using coffee.

My List:

@list = blessed.list {
  label: ' {red-fg}{bold}Features{/bold}{/red-fg} ',
  width: '20%',
  height: '100%',
  tags: true,
  keys: true,
  vi:   false,
  border: {
    type: 'line'
  },
  style: {
    fg: 'white',
    border: {
      fg: '#f0f0f0'
    },
  }
}

My Listener: @list.on('select', (item, index) => @itemSelected(index))

chjj commented 9 years ago

If I had to guess without looking, this is most likely due to the dissonance between return and enter - two events get fired. Because different node versions change emitKeypressEvents, it's probably wise to add our own custom keypress parser there.