+# This is not supposed to be a complete list
+# it is just to improve readability in this file
+keys = {
+	TAB: 9
+	ENTER: 13
+	ESC: 27
+	ARROW_LEFT: 37
+	ARROW_UP: 38
+	ARROW_RIGHT: 39
+	ARROW_DOWN: 40
+}
+
 getCursorPosition = (input) ->
 	if not input? then return
 	if input.selectionStart?

		if template.open.curValue isnt true or template.hasData.curValue isnt true
			return

		if event.which in [38, 40]
			event.preventDefault()
			event.stopPropagation()

		if event.which in [13, 9]
			template.open.set false

			template.enterValue()

			event.preventDefault()
			event.stopPropagation()

	template.setTextFilter = _.debounce (value) ->
		template.textFilter.set(value)
	, template.textFilterDelay

	template.onInputKeyup = (event) =>
		if template.open.curValue is true and event.which is 27
			template.open.set false
			event.preventDefault()
			event.stopPropagation()

		if template.open.curValue isnt true
			return

		if event.which not in [keys.ARROW_UP, keys.ARROW_DOWN]
			Meteor.defer =>
				template.verifySelection()

