mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-11 11:54:06 +00:00
Add Keys enum; use it when detecting keystrokes in the input suggestions component.
This commit is contained in:
parent
bebbc433bf
commit
522084a504
3 changed files with 19 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
|||
define [
|
||||
"base"
|
||||
], (App) ->
|
||||
inputSuggestionsController = ($scope, $element, $attrs) ->
|
||||
inputSuggestionsController = ($scope, $element, $attrs, Keys) ->
|
||||
ctrl = @
|
||||
ctrl.showHint = false
|
||||
ctrl.hasFocus = false
|
||||
|
@ -14,7 +14,7 @@ define [
|
|||
ctrl.suggestion = null
|
||||
ctrl.onBlur()
|
||||
ctrl.handleKeyDown = ($event) ->
|
||||
if ($event.which == 9 or $event.which == 13) and ctrl.suggestion? and ctrl.suggestion != ""
|
||||
if ($event.which == Keys.TAB or $event.which == Keys.ENTER) and ctrl.suggestion? and ctrl.suggestion != ""
|
||||
$event.preventDefault()
|
||||
ctrl.localNgModel += ctrl.suggestion
|
||||
ctrl.suggestion = null
|
||||
|
|
|
@ -22,6 +22,7 @@ define [
|
|||
"main/learn"
|
||||
"main/affiliations/controllers/UserAffiliationsController"
|
||||
"main/affiliations/factories/UserAffiliationsDataService"
|
||||
"main/keys"
|
||||
"analytics/AbTestingManager"
|
||||
"directives/asyncForm"
|
||||
"directives/stopPropagation"
|
||||
|
|
16
services/web/public/coffee/main/keys.coffee
Normal file
16
services/web/public/coffee/main/keys.coffee
Normal file
|
@ -0,0 +1,16 @@
|
|||
define [
|
||||
"base"
|
||||
], (App) ->
|
||||
App.constant "Keys",
|
||||
ENTER : 13
|
||||
TAB : 9
|
||||
ESCAPE : 27
|
||||
SPACE : 32
|
||||
BACKSPACE : 8
|
||||
UP : 38
|
||||
DOWN : 40
|
||||
LEFT : 37
|
||||
RIGHT : 39
|
||||
PERIOD : 190
|
||||
COMMA : 188
|
||||
END : 35
|
Loading…
Add table
Reference in a new issue