I am building an auto suggest feature to my PM system and I just can't seem to figure this out. Essentially once the auto suggest appears, I can click on someone and they'll be added to a message, but I also want that same functionality working when I press the enter key. My file structure consists of a search.lib.js file and a page.js file. The search.lib.js file contains all of the related OOP search functions. The page.js file controls all of the JS on that page.

My search file is what generates the ajax and onclick of the menu... it runs a function... user_add

Code JavaScript:
function user_add(this_info, search){
		var with_field		= document.getElementById('users');
		var wsh			= document.getElementById('wsh');
		span_user			= document.createElement('span');
		remove_user		= document.createElement('a');
		user_input_hid 		= document.createElement('input');
 
		i = this_info.lastChild.value;
		//console.log(this_info.children[1].innerHTML);
 
		span_user.id = 'with_' + search[i]['uid'];
		span_user.className = 'with_pick f_left';
		span_user.innerHTML = search[i]['firstname'] + ' ' + search[i]['lastname'];
 
		user_input_hid.type = 'hidden';
		user_input_hid.name = 'with_uid[]';
		user_input_hid.value = search[i]['uid'];
 
		appendText(remove_user, 'x');
		remove_user.href = '#';
		remove_user.className = 'with_remove';
 
		span_user.appendChild(remove_user);
		span_user.appendChild(user_input_hid);
		wsh.appendChild(span_user);
 
		with_field.value = '';
		with_field.focus();
 
		remove_user.onclick = function (){
 
			var invite_avatars = document.getElementById('inviteavatars');
 
			if (invite_avatars)
			{
				var avi_id = 'avi_' + this.parentNode.id.substr(5);
 
				removeElementById(avi_id);
			}
 
			removeElementById(this.parentNode.id);
 
			return false;
		}
 
		associate_search.hide();
 
		return false;
	}

but when I press the enter key I reference user_add(), but search is not defined. And search is only defined in the search.lib.js file. So I supposed I could create a bunch of hidden input to pass through the values that I need but I would rather not do that. Please provide me with some suggestions.

Code JavaScript:
                       else if (is_key(event, 13)){
				//enter is pressed.  Send the user to the link in the li.
				var search_list_ele_array = new Array();
				var search_list_ele_array = document.getElementById('with_auto').getElementsByTagName('li');
 
				for (j=0; j<search_list_ele_array.length; j++) {
 
					if ((search_list_ele_array[j].className == 'user list_hover') || (search_list_ele_array[j].className == 'comp list_hover') || (search_list_ele_array[j].className == 'blog list_hover')){
						var link = search_list_ele_array[j].getElementsByTagName('a');
						associate_search.user_add(link, search);
					}
				}
 
				return false;
			}