text: 'use strict';
  
  angular.module('view-form').directive('keyToOption', function(){
  	return {
  		restrict: 'A',
  		scope: {
  			field: '='
  		},
  		link: function($scope, $element, $attrs, $select) {
  			$element.bind('keydown keypress', function(event) {
  
  				var keyCode = event.which || event.keyCode;
  				var index = parseInt(String.fromCharCode(keyCode))-1;
  				//console.log($scope.field);
  
  				if (index < $scope.field.fieldOptions.length) {
  					event.preventDefault();
  					$scope.$apply(function () {
  						$scope.field.fieldValue = $scope.field.fieldOptions[index].option_value;
  					});
  				}
  
  			});
  		}
  	};
  });
  