Hello i'm trying to make this code shorter in coffee script ... what do 
you suggest? i'm new to coffee script and just want to know how i would 
shorten this command

keyDownHandler = (event) ->
  selectedItem = 
$(event.target).siblings(".suggestions").children(".current-suggestion")
  if selectedItem.length > 0
    if event.which is 40
      nextItem = 
$(selectedItem).removeClass("current-suggestion").next()
      nextItem.addClass "current-suggestion" if nextItem.length > 0
      return
    if event.which is 38
      nextItem = 
$(selectedItem).removeClass("current-suggestion").prev()
      nextItem.addClass "current-suggestion" if nextItem.length > 0
      return
    if event.which is 13 or event.which is 9
      addSuggestion(event.target)(selectedItem)
      event.preventDefault()
      return

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to