Make Ctrl+Enter "OK" close a multi-line custom edit dialog

It is possible to close the multi-line custom edit dialog when pressing Ctrl+Enter, just like clicking the OK button to close?

/*
===================================================================================================
AUTHOR   : Ken
Function : Set Tags & Add Tags by List
Created  : 2022-12-07
Modified : 2022-12-23
Version  : v1.1
===================================================================================================
*/



// Set Tags. Add Tags by List.
// (c) 2022 Ken

// This is a script for Directory Opus.
// See https://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.



// Called by Directory Opus to initialize the script
function OnInit(initData)
{
	initData.name = "Set Tags. Add Tags by List.";
	initData.version = "1.1";
	initData.copyright = "(c) 2022 Ken";
//	initData.url = "https://resource.dopus.com/c/buttons-scripts/16";
	initData.desc = "atbl, settag";
	initData.default_enable = true;
	initData.min_version = "12.0";
}


function OnAddCommands(addCmdData)
{
    var cmd = addCmdData.AddCommand();
    cmd.name = "atbl";
    cmd.method = "Onatbl";
    cmd.desc = "Add Tags by List";
    cmd.label = "atbl";

	var cmd2 = addCmdData.AddCommand();
	cmd2.name = "settag";
	cmd2.method = "OnSetTag";
	cmd2.desc = "Set Tags";
	cmd2.label = "settag";

    cmd.template = "";
    cmd.hide = false;
    cmd.icon = 'script';
}


 // Add string trim() method
 String.prototype.trim = function(s){s=s||"\\s";return this.replace(new RegExp("^("+s+"){1,}\|("+s+"){1,}$","g"),"");}
 var fsu = DOpus.FSUtil;
 var ST = DOpus.Create.StringTools();
 var cmd = DOpus.Create().Command();


function OnSetTag(scriptCmdData) {

    InitTags();
    var dlgEdit = scriptCmdData.func.Dlg();
    var tab = scriptCmdData.func.sourcetab;
    var cmd = scriptCmdData.func.command;

    dlgEdit.title = "Directory Opus";
    dlgEdit.template = "dlgSetTags";
    dlgEdit.detach = true;
    dlgEdit.Create();

	dlgEdit.Control("static").style = "b";
	dlgEdit.Control("static").label = 'Set Tags';                               // Topic
	dlgEdit.Control("static2").label = 'One tag per line, or enter new tags sepratted with ", "';     // Notes
	dlgEdit.Control("static3").label = Script.LoadImage("Label.png");           // Icon

    var ADS = tab.vars.Get('ADScheck');
	dlgEdit.Control("SetTags").value = ADS;                                     // Default value

    dlgEdit.Show();

// msg loop
	do
	{
	   msg = dlgEdit.GetMsg();

       // Result
	   if (dlgEdit.result == 1)
	   {
		   var newTags = dlgEdit.Control("SetTags").value;
		   newTags = format_tags(newTags);

// Add the new tags to the selected items and restore the timestamp
	       if (newTags != "")
	       {
		       cmd.deselect = false;
		       var modified, ADSfile, fileWrite, eItem;

               for (var eSel = new Enumerator(tab.selected); !eSel.atEnd(); eSel.moveNext())
	           {
			        eItem = eSel.item();
			        modified = eItem.modify;
                    ADSfile =  eSel.item() + ":Tags";
	                fileWrite = fsu.OpenFile(ADSfile, "wa");
	                if (fileWrite.error == 0)
	                {
	                    fileWrite.Write(newTags);
	                }
	                fileWrite.Close;
			        modified = modified.Format("D#yyyy-MM-dd T#HH:mm:ss") 
			        //cmd.Runcommand('SetAttr MODIFIED "'+ modified +'"')
			        cmd.RunCommand ('SetAttr "' + eItem + '" Meta "lastmodifieddate:' + modified + '"')
	           }
	           cmd.Runcommand("RefreshColumnADS");   // Refresh column
	        }

           var array = newTags.split(", ");
		   var tags = tab.vars.Get('DOpusTag');
		   var tagsArray = tags.split(", ");                            // Seprator
           var newTags2 = "", tagCase;

           // Remove Duplicate
		   for (i = 0; array[i]; i++)
		   {
			    tagCase = "";
		        for (ii = 0; tagsArray[ii]; ii++)
				{
				     if (array[i] == tagsArray[ii])
					 {
						 tagCase = 1;
					 }
				}

			    if (tagCase != 1)
				{
					newTags2 += array[i] + ", ";
				}
           }
		   var newTags3 = newTags2 + tags;
           tab.vars.Set('DOpusTag', newTags3);

           // Write new tags to DOpusTag.dat
		   var tagFile = "%appdata%\\GPSoftware\\Directory Opus\\Scripts\\INI\\DOpusTag.dat";   // File path
		   var oFileWrite = fsu.OpenFile(tagFile, "wa");
           var utf8bom = ST.Encode(newTags3	, "utf-8 bom");   // Decode as UTF-8 with BOM
           if (oFileWrite.error == 0)
           {
               oFileWrite.Write(utf8bom)
           }
              oFileWrite.Close()
	   }
	} while (msg == true)
}


function Onatbl(scriptCmdData)
{
    var dlg = scriptCmdData.func.Dlg();
    var tab = scriptCmdData.func.sourcetab;
    var cmd = scriptCmdData.func.command;

    var strName;

    dlg.title = "Directory Opus";
    dlg.template = "dlgList";
    dlg.detach = true;
    dlg.Create();
	dlg.Control("static").label = "Add Tags by List";                       // Topic
	dlg.Control("static2").label = "Tick the tags that shall be added to the tags of the selected items.";   // Notes
	dlg.Control("static3").label = Script.LoadImage("Label.png");           // Icon
	dlg.Control("static4").label = Script.LoadImage("Find.png");            // Icon
	//dlg.Control("static5").label = "D:\\Icons\\Clear.png";                  // Clear

    updateList(dlg, strName);

    dlg.Show();

	var lst = dlg.Control("list");
	var col = lst.columns;



    while (true)
	{
        var msg = dlg.GetMsg();
        if (!msg.result) break;

// Result
        if (msg.event == "focus" || dlg.Control("btnOK").focus == true)
		{
		   var tags = "";
           for (i=0; i < lst.count; i ++)
		   {
                if (lst.GetItemAt(i).checked == 1)
				{
				    tags += lst.GetItemAt(i).name;
					tags += ", ";
                }
           }
		}

// Right click list menu
        if (msg.event == "rclick" && lst.focus == true)
		{

            var dlgMenu = scriptCmdData.func.Dlg();

            if (lst.value.index > -1)
			{
				dlgMenu.choices = DOpus.Create.Vector("New", "Edit", "Delete", "Clear Filter", "Refresh", "Copy", "Cancel");
				dlgMenu.menu = DOpus.Create.Vector(1, 0, 0, 0, 0, 0, 1);
            } else {
				dlgMenu.choices = DOpus.Create.Vector("OK", "Cancel");
                dlgMenu.menu = DOpus.Create.Vector(1, 1);
            }
            var menuReturn = dlgMenu.Show;

            if (menuReturn == 1) {
				NewTags(scriptCmdData);
				updateList(dlg, strName);
            }

            if (menuReturn == 2) {
				var editTag = lst.GetItemAt(lst.value.index).name;
				tab.vars.Set('editTag', editTag);
				EditTag(scriptCmdData);
				updateList(dlg, strName);
            }

            if (menuReturn == 3) {
				var deleteTag = lst.GetItemAt(lst.value.index).name;
				tab.vars.Set('deleteTag', deleteTag);
				DeleteTag(scriptCmdData);
				updateList(dlg, strName);
            }

            if (menuReturn == 4) {
                dlg.Control("editFilter").value = "";
			    updateList(dlg, strName);
            }

            if (menuReturn == 5) {
				updateList(dlg, strName);
            }

            if (menuReturn == 6) {
                var item = lst.GetItemAt(lst.value.index).name;
				DOpus.SetClip(item);
            }
        }

// Filter
		if (msg.event == "editchange" || msg.event == "click")
		{
			updateList(dlg, strName);
		}

    }


// Add the checked tags to the selected items and restore the timestamp
	if (tags != "" && dlg.result == 1)
	{
	    tags = tags.substr(0, tags.length-2);
		cmd.deselect = false;
		var modified, ADSfile, fileWrite, eItem;
		
        for (var eSel = new Enumerator(tab.selected); !eSel.atEnd(); eSel.moveNext())
	    {
			 eItem = eSel.item();
			 modified = eItem.modify;
             ADSfile =  eSel.item() + ":Tags";
	         fileWrite = fsu.OpenFile(ADSfile, "wa");
	         if (fileWrite.error == 0)
	         {
	             fileWrite.Write(tags);
	         }
	         fileWrite.Close;
			 modified = modified.Format("D#yyyy-MM-dd T#HH:mm:ss") 
			 //cmd.Runcommand('SetAttr MODIFIED "'+ modified +'"')
			 cmd.RunCommand ('SetAttr "' + eItem + '" Meta "lastmodifieddate:' + modified + '"')
	    }
	    cmd.Runcommand("RefreshColumnADS");   // Refresh column
	}
}



function updateList(dlg, strName) {

    if (!DOpus.version.AtLeast("12.30.1"))
    {
	    dlg.request("This script requires 12.30.1 and above!", "OK");
		return
    }

    InitTags();
    var lst = dlg.Control("list");
	var col = lst.columns;

// Add columns
	var vecOrder = col.GetDisplayOrder();
    if (vecOrder.size < 1)
	{
	    col.AddColumn("0:Name");
	    col.AddColumn("1:Index");
	}

    lst.redraw = false;
    lst.RemoveItem(-1);
    var tab = DOpus.listers.lastactive.activetab;

// List items
    //var text = "tag1, tag2, tag3, tag4, tag5, tag6, tag7, tag8, tag9, tag10, tag11, tag12, tag13, tag14, tag15, tag16, tag17, tag18, tag19, tag20, tag21, tag22, tag23, tag24, tag25, tag26, tag27, tag28, tag29, tag30, tag31, tag32, tag33, tag34, tag35";
	var text = tab.vars.Get('DOpusTag');
	var myArray = text.split(", ");                           // Seprator

	var idx;
	var count = 0;
	var ii = 0;

    // Get var ADScheck
    var ADS = tab.vars.Get('ADScheck');

// Add checked list
    if (ADS != "")
	{
	    var array = ADS.split(", ");                          // Seprator
		for (i = 0; array[i]; i++)
		{
		     count++;
			 var checkedTag = array[i];

	         var strFilter = dlg.Control("editFilter").value;   // Get filter value
	         strFilter = strFilter.toLowerCase();

		     if (checkedTag.search(strFilter) == -1) {
			     continue;
		     }
	         idx = lst.AddItem(array[i]);                     // Add each item to list
             lst.GetItemAt(idx).subitems(0) = count;          // Add number to column 1 (Index)
			 lst.GetItemAt(idx).checked = 1;

             ii++;
			 var checkedCase = 1;
			 checkedTag = "";
			 strFilter = "";
	    }
    }

// Add list
    var tagCase;
    for (i = 0; myArray[i]; i++)
	{
        strName = myArray[i];
		var strRealName = myArray[i];

        // Remove Duplicate
        tagCase = "";
		if (checkedCase == 1)
		{
			for (ii = 0; array[ii]; ii++)
			{
				if (array[ii] == strName)
				{
					tagCase	= 1;
				}
			}
		}

	    var strFilter = dlg.Control("editFilter").value;      // Get filter value
	    strFilter = strFilter.toLowerCase();

		if (strRealName.search(strFilter) == -1) {
			continue;
		}

        if (tagCase == "")
		{
			count++;
            idx = lst.AddItem(strName);                       // Add each item to list
		    lst.GetItemAt(idx).subitems(0) = count;           // Add number to column 1 (Index)

            ii++;
		    strRealName = "";
		    strFilter = "";
		}
    }

// Set the columns display order
	if (true)
	{
	    col.SetDisplayOrder(1,0);
	}

// Resize columns based on number of lists
    //col.AutoSize();
	col.GetColumnAt(1).width = String(i).length+25;
	if (ii > 27)
	{
	   col.GetColumnAt(0).width = 420-String(i).length;
	}
	else
	{
	   col.GetColumnAt(0).width = 437-String(i).length;
	}
	lst.redraw = true;
}



function InitTags() {

 var tab = DOpus.listers.lastactive.activetab;
 // Create folder if does not exist
 if (!DOpus.FSUtil.Exists("%appdata%\\GPSoftware\\Directory Opus\\Scripts\\INI\\"))
 {
	 cmd.Runcommand('CreateFolder "%appdata%\\GPSoftware\\Directory Opus\\Scripts\\INI\\"');
 }


// Get ADS of the selected items 
 var eItem, ADSfile, text, textbom, myArray, ADS2, ADS = "", i = 0;

 for (var eSel = new Enumerator(tab.selected); !eSel.atEnd(); eSel.moveNext())
 {
	  i++;
	  ADS2 = ADS;
	  eItem = eSel.item();
      ADSfile =  eItem + ":Tags";
      // If ADSfile exists
      if (fsu.Exists(ADSfile))
      {
          text = fsu.OpenFile(ADSfile).Read();          // Read file
          textbom = ST.Decode(text, "utf-8 bom");       // Decode as UTF-8 with BOM
          myArray = textbom.split("\r\n");              // The seprator is \r\n
          ADS = myArray[0];                             // Get the first line
      }
      else {ADS = ""; break}
	  if (i > 1 && ADS != ADS2) {ADS = ""; break};
 }
 ADS = format_tags(ADS);
 tab.vars.Set('ADScheck', ADS);

// Read the tag file DOpusTag.dat and set it to variable DOpusTag
 var tagFile = "%appdata%\\GPSoftware\\Directory Opus\\Scripts\\INI\\DOpusTag.dat";   // File path
 if (DOpus.FSUtil.Exists(tagFile))
 {
     var tags = fsu.OpenFile(tagFile).Read();
     tags = ST.Decode(tags, "utf-8 bom");
 } else {var tags = "";}
 tab.vars.Set('DOpusTag', tags);
}



function NewTags(scriptCmdData) {

    var dlgEdit = scriptCmdData.func.Dlg();
    var tab = scriptCmdData.func.sourcetab;

    dlgEdit.title = "Directory Opus";
    dlgEdit.template = "dlgEditTags";
    dlgEdit.detach = true;
    dlgEdit.Create();

	dlgEdit.Control("static").style = "b";
	dlgEdit.Control("static").label = 'Enter new Tags';                         // Topic
	dlgEdit.Control("static2").label = 'One tag per line, or enter new tags sepratted with ", "';     // Notes
	dlgEdit.Control("static3").label = Script.LoadImage("Edit-new.png");        // Icon

	dlgEdit.Control("editTags").value = "";                                     // Default value

    dlgEdit.Show();

// msg loop
	do
	{
	   msg = dlgEdit.GetMsg();

       // Result
	   if (dlgEdit.result == 1)
	   {
		   var newTags = dlgEdit.Control("editTags").value;
           newTags = format_tags(newTags);
		   var array = newTags.split(", ");                             // Seprator

		   var tags = tab.vars.Get('DOpusTag');
		   var tagsArray = tags.split(", ");                            // Seprator
           var newTags = "", tagCase;

           // Remove Duplicate
		   for (i = 0; array[i]; i++)
		   {
			    tagCase = "";
		        for (ii = 0; tagsArray[ii]; ii++)
				{
				     if (array[i] == tagsArray[ii])
					 {
						 tagCase = 1;
					 }
				}

			    if (tagCase != 1)
				{
					newTags += array[i] + ", ";
				}
           }
		   var newTags2 = newTags + tags;
           tab.vars.Set('DOpusTag', newTags2);

           // Write new tags to DOpusTag.dat
		   var tagFile = "%appdata%\\GPSoftware\\Directory Opus\\Scripts\\INI\\DOpusTag.dat";   // File path
		   var oFileWrite = fsu.OpenFile(tagFile, "wa");
           var utf8bom = ST.Encode(newTags2	, "utf-8 bom");   // Decode as UTF-8 with BOM
           if (oFileWrite.error == 0)
           {
               oFileWrite.Write(utf8bom)
           }
              oFileWrite.Close()
	   }
	} while (msg == true)
}



function EditTag(scriptCmdData) {

    var dlgEdit = scriptCmdData.func.Dlg();
    var tab = scriptCmdData.func.sourcetab;

    dlgEdit.title = "Directory Opus";
    dlgEdit.template = "dlgEditTags";
    dlgEdit.detach = true;
    dlgEdit.Create();

	dlgEdit.Control("static").style = "b";
	dlgEdit.Control("static").label = 'Edit Tags';                              // Topic
	dlgEdit.Control("static2").label = 'One tag per line, or enter new tags sepratted with ", "';     // Notes
	dlgEdit.Control("static3").label = Script.LoadImage("Edit.png");            // Icon

	var editTag = tab.vars.Get('editTag', editTag);
	dlgEdit.Control("editTags").value = editTag;                                // Default value

    dlgEdit.Show();

// msg loop
	do
	{
	   msg = dlgEdit.GetMsg();

       // Result
	   if (dlgEdit.result == 1)
	   {
		   var newTag = dlgEdit.Control("editTags").value;
           newTag = format_tags(newTag);
		   if (newTag == "") {return};

		   // Remove duplicate
	       var tags = tab.vars.Get('DOpusTag');
		   var tagsArray = newTag.split(", ");
		   var tagsArray2 = tags.split(", ");                            // Seprator

		   var tagCase, newTags = "";
		   for (i = 0; tagsArray2[i]; i++)
		   {
			    tagCase = "";
			    for (ii = 0; tagsArray[ii]; ii++)
				{
				     if (tagsArray2[i] == tagsArray[ii])
					 {
						 tagCase = 1;
					 }
				}
				if (tagCase != 1 && tagsArray2[i] != editTag)
				{
					newTags += tagsArray2[i] + ", ";
				}
		   }

		   newTags = newTag + ", " + newTags;
		   newTags = newTags.substr(0, newTags.length-2);
           tab.vars.Set('DOpusTag', newTags);

           // Write new tags to DOpusTag.dat
		   var tagFile = "%appdata%\\GPSoftware\\Directory Opus\\Scripts\\INI\\DOpusTag.dat";   // File path
		   var oFileWrite = fsu.OpenFile(tagFile, "wa");
           var utf8bom = ST.Encode(newTags, "utf-8 bom");   // Decode as UTF-8 with BOM
           if (oFileWrite.error == 0)
           {
               oFileWrite.Write(utf8bom)
           }
              oFileWrite.Close()
	   }
	} while (msg == true)
}



function DeleteTag(scriptCmdData) {

    var tab = scriptCmdData.func.sourcetab;
    var deleteTag = tab.vars.Get('deleteTag');
	if (deleteTag == "") return;

	var tags = tab.vars.Get('DOpusTag');
	var tagsArray = tags.split(", ");                           // Seprator
	var newTags = "";
	for (i = 0; tagsArray[i]; i++)
	{
	     if (tagsArray[i] != deleteTag)
		 {
			 newTags += tagsArray[i] + ", ";
         }
	}

    newTags = newTags.substr(0, newTags.length-2)
    tab.vars.Set('DOpusTag', newTags);

    // Write new tags to DOpusTag.dat
	var tagFile = "%appdata%\\GPSoftware\\Directory Opus\\Scripts\\INI\\DOpusTag.dat";   // File path
	var oFileWrite = fsu.OpenFile(tagFile, "wa");
    var utf8bom = ST.Encode(newTags, "utf-8 bom");   // Decode as UTF-8 with BOM
    if (oFileWrite.error == 0)
    {
        oFileWrite.Write(utf8bom)
    }
        oFileWrite.Close()
}



function format_tags(str){

    var array = String(str).split(",");                                // Seprator
	var newTag1 = array[0].trim().replace(/\|/g,'');
	if (newTag1 == "") {return newTag1};

    var tag, newTags = "";
	for (i = 0; array[i]; i++)
	{
		 tag = array[i].trim().replace(/\|/g,'');
		 newTags += tag + ", ";
    }
	newTags = newTags.substr(0, newTags.length-2);

    var array2 = newTags.split("\r\n");                                // Seprator
	newTags = "";
	for (i = 0; array2[i]; i++)
	{
		 tag = array2[i].trim().replace(/\|/g,'');
		 newTags += tag + ", ";
	}
	newTags = newTags.substr(0, newTags.length-2);
	return newTags;
}



==SCRIPT RESOURCES
<resources>
	<resource name="dlgEditTags" type="dialog">
		<dialog fontsize="8" height="120" lang="english" resize="yes" title="Edit Tags" width="522">
			<control halign="left" height="62" multiline="yes" name="editTags" resize="wh" type="edit" width="506" x="8" y="32" />
			<control close="1" default="yes" height="14" name="btnApply" resize="xy" title="&amp;Apply" type="button" width="50" x="409" y="99" />
			<control close="0" height="14" name="btnCancel" resize="xy" title="&amp;Cancel" type="button" width="50" x="462" y="99" />
			<control halign="left" height="8" name="static" title="Edit Tags" type="static" valign="top" width="472" x="39" y="7" />
			<control halign="left" height="20" image="yes" name="static3" title="Static" type="static" valign="top" width="20" x="10" y="4" />
			<control halign="left" height="8" name="static2" title="Notes" type="static" valign="top" width="472" x="39" y="17" />
		</dialog>
	</resource>
	<resource name="dlgList" type="dialog">
		<dialog fontsize="9" height="350" lang="english" resize="yes" title="Directory Opus" width="279">
			<control halign="left" height="12" name="editFilter" resize="xy" tip="Filter" type="edit" width="118" x="21" y="331" />
			<control checkboxes="auto" fullrow="yes" height="287" name="list" noheader="yes" resize="wh" type="listview" viewmode="details" width="266" x="6" y="40" />
			<control close="1" default="yes" height="12" name="btnOK" resize="xy" title="&amp;OK" type="button" width="42" x="184" y="332" />
			<control close="0" height="12" name="btnClose" resize="xy" title="C&amp;ancel" type="button" width="42" x="229" y="332" />
			<control halign="left" height="8" name="static" title="Topic" type="static" valign="top" width="245" x="25" y="7" />
			<control halign="left" height="13" image="yes" name="static3" title="Static" type="static" valign="top" width="13" x="7" y="8" />
			<control halign="left" height="12" image="yes" name="static4" resize="xy" title="Static" type="static" valign="top" width="12" x="8" y="331" />
			<control halign="left" height="16" name="static2" title="Notes" type="static" valign="top" width="245" x="25" y="20" />
			<control halign="left" height="5" name="static5" title="Static" type="static" valign="top" width="6" x="130" y="335" />
		</dialog>
	</resource>
	<resource name="dlgSetTags" type="dialog">
		<dialog fontsize="8" height="120" lang="english" resize="yes" title="Set Tags" width="522">
			<control halign="left" height="62" multiline="yes" name="SetTags" resize="wh" type="edit" width="506" x="8" y="32" />
			<control close="1" default="yes" height="14" name="btnOK" resize="xy" title="&amp;OK" type="button" width="50" x="409" y="99" />
			<control close="0" height="14" name="btnCancel" resize="xy" title="&amp;Cancel" type="button" width="50" x="462" y="99" />
			<control halign="left" height="8" name="static" title="Set Tags" type="static" valign="top" width="472" x="39" y="6" />
			<control halign="left" height="20" image="yes" name="static3" title="Static" type="static" valign="top" width="20" x="10" y="4" />
			<control halign="left" height="8" name="static2" title="Notes" type="static" valign="top" width="472" x="40" y="17" />
		</dialog>
	</resource>
</resources>

You'll get a Msg where the event is "editchange" each time the text in the edit control changes. You could use that to see if it goes from having 1 new line at the end to 2.

But how do I let the script know that I pressed Ctrl+Enter? (Enter and Ctrl+Enter seem to be the same.) Then let script close the custom dialog.

The Msg object tells you if Ctrl was down in the qualifiers field.

I've made Ctrl+Enter close the dialog, but Ctrl+V will also close the dialog, I can't find an event that I can distinguish.

    var newTags, tagsTMP = "|";

// msg loop
	do
	{
	   //DOpus.Output(msg.control);
	   //DOpus.Output(msg.data);
	   //DOpus.Output(msg.event);
	   //DOpus.Output(msg.focus);
	   //DOpus.Output(msg.index);
	   //DOpus.Output(msg.object);
	   DOpus.Output(msg.qualifiers);
	   DOpus.Output(msg.value);

	   msg = dlgEdit.GetMsg();
	   if (msg.qualifiers == "none") {tagsTMP = dlgEdit.Control("SetTags").value};

       // Result
	   if (dlgEdit.result == 1 || msg.qualifiers == "ctrl" && msg.event == "editchange")
	   {
		   if (msg.qualifiers == "ctrl" && msg.event == "editchange")
		   {
			   dlgEdit.EndDlg;
			   if (tagsTMP != "|")
			   {
				   newTags = tagsTMP
			   } else {newTags = ADS}
		   } else
		   {
			   newTags = dlgEdit.Control("SetTags").value
		   }
       }
	}

Set Tags & Add Tags by List (v1.2).js.txt (25.7 KB)

Looks like you’ve checking for Ctrl but not what’s in the edit control.

Seems to be solved, but it looks weird. . .

// msg loop
	do
	{
	   dlgValueOld = dlgEdit.Control("editTags").value;
	   msg = dlgEdit.GetMsg();

	   if (msg == true)
	   {
		   dlgValue = dlgEdit.Control("editTags").value;
	   }

	   if (msg.qualifiers == "none") {tagsTMP = dlgEdit.Control("editTags").value};

	   var dlgValueArray = dlgValue.split("\r\n");
	   var newDlgValue = "";
	   for (i = 0; dlgValueArray[i]; i++)
	   {
		   newDlgValue += dlgValueArray[i]
	   }

	   var OldArray = dlgValueOld.split("\r\n");
	   var dlgValueOld2 = "";
	   for (i = 0;OldArray[i]; i++)
	   {
		   dlgValueOld2 += OldArray[i]
	   }

       // Result
	   if (dlgEdit.result == 1 || msg.qualifiers == "ctrl" && msg.event == "editchange" && newDlgValue == dlgValueOld2 || msg.qualifiers == "ctrl" && msg.event == "editchange" && dlgValue.trim() == tagsTMP)
	   {
		   if (msg.qualifiers == "ctrl" && msg.event == "editchange" && dlgValue.trim() == tagsTMP)
		   {
			   dlgEdit.EndDlg; newTags =dlgValue
		   }
		   else
		   if (msg.qualifiers == "ctrl" && msg.event == "editchange" && newDlgValue == dlgValueOld2)
		   {
			   dlgEdit.EndDlg;
			   newTags = dlgValueOld
		   }
		   else
		   {
			   newTags = dlgEdit.Control("editTags").value
		   }
       }
}

Edit:
It would be nice to be able to get the Enter key status, hopefully there will be no new problems. :sweat_smile:
Edit2:
Wow! It's getting longer and longer!

    DOpus.ClearOutput;
	var newTags, tagsTMP = "|", dlgValueOld, dlgValue = "";

// msg loop
	do
	{
	   dlgValueOld = dlgEdit.Control("SetTags").value;
	   msg = dlgEdit.GetMsg();

	   if (msg == true) {dlgValue = dlgEdit.Control("SetTags").value};

	   if (msg.qualifiers == "none") {tagsTMP = dlgEdit.Control("SetTags").value};

	   var dlgValueArray = dlgValue.split("\r");
	   var newDlgValue = "";
	   for (i = 0; dlgValueArray[i]; i++)
	   {
		   newDlgValue += dlgValueArray[i].trim();
	   }

	   var OldArray = dlgValueOld.split("\r");
	   var dlgValueOld2 = "";
	   for (i = 0;OldArray[i]; i++)
	   {
		   dlgValueOld2 += OldArray[i].trim()
	   }

       // Result
	   if (dlgEdit.result == 1 || msg.qualifiers == "ctrl" && msg.event == "editchange" && newDlgValue == dlgValueOld2 && dlgValue != DOpus.GetClip || msg.qualifiers == "ctrl" && msg.event == "editchange" && dlgValue.trim() == tagsTMP.trim() || msg.qualifiers == "ctrl" && msg.event == "editchange" && dlgValueArray[0].trim() == "" && dlgValue.trim() != "")
	   {
		   if (msg.qualifiers == "ctrl" && msg.event == "editchange" && dlgValueArray[0].trim() == "" && dlgValue.trim() != "")
		   {
			   dlgEdit.EndDlg;
			   //DOpus.Output("0")
			   newTags = dlgValue
		   }
		   else
		   if (msg.qualifiers == "ctrl" && msg.event == "editchange" && dlgValue.trim() == tagsTMP.trim())
		   {
			   dlgEdit.EndDlg;
			   //DOpus.Output("1")
			   newTags = dlgValue
		   }
		   else
		   if (msg.qualifiers == "ctrl" && msg.event == "editchange" && newDlgValue == dlgValueOld2 && dlgValue != DOpus.GetClip)
		   {
			   dlgEdit.EndDlg;
			   //DOpus.Output("2")
			   newTags = dlgValueOld
		   }
		   else
		   {
			   newTags = dlgEdit.Control("SetTags").value
			   //DOpus.Output("3")
		   }    DOpus.ClearOutput;
	var newTags, tagsTMP = "|", dlgValueOld, dlgValue = "";

// msg loop
	do
	{
	   dlgValueOld = dlgEdit.Control("SetTags").value;
	   msg = dlgEdit.GetMsg();

	   if (msg == true) {dlgValue = dlgEdit.Control("SetTags").value};

	   if (msg.qualifiers == "none") {tagsTMP = dlgEdit.Control("SetTags").value};

	   var dlgValueArray = dlgValue.split("\r");
	   var newDlgValue = "";
	   for (i = 0; dlgValueArray[i]; i++)
	   {
		   newDlgValue += dlgValueArray[i].trim();
	   }

	   var OldArray = dlgValueOld.split("\r");
	   var dlgValueOld2 = "";
	   for (i = 0;OldArray[i]; i++)
	   {
		   dlgValueOld2 += OldArray[i].trim()
	   }

       // Result
	   if (dlgEdit.result == 1 || msg.qualifiers == "ctrl" && msg.event == "editchange" && newDlgValue == dlgValueOld2 && dlgValue != DOpus.GetClip || msg.qualifiers == "ctrl" && msg.event == "editchange" && dlgValue.trim() == tagsTMP.trim() || msg.qualifiers == "ctrl" && msg.event == "editchange" && dlgValueArray[0].trim() == "" && dlgValue.trim() != "")
	   {
		   if (msg.qualifiers == "ctrl" && msg.event == "editchange" && dlgValueArray[0].trim() == "" && dlgValue.trim() != "")
		   {
			   dlgEdit.EndDlg;
			   DOpus.Output("0")
			   newTags = dlgValue
		   }
		   else
		   if (msg.qualifiers == "ctrl" && msg.event == "editchange" && dlgValue.trim() == tagsTMP.trim())
		   {
			   dlgEdit.EndDlg;
			   DOpus.Output("1")
			   newTags = dlgValue
		   }
		   else
		   if (msg.qualifiers == "ctrl" && msg.event == "editchange" && newDlgValue == dlgValueOld2 && dlgValue != DOpus.GetClip)
		   {
			   dlgEdit.EndDlg;
			   DOpus.Output("2")
			   newTags = dlgValueOld
		   }
		   else
		   {
			   newTags = dlgEdit.Control("SetTags").value
			   DOpus.Output("3")
		   }
		}
    }