{"id":55818,"date":"2022-09-22T03:01:30","date_gmt":"2022-09-21T17:01:30","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=55818"},"modified":"2022-09-13T14:03:58","modified_gmt":"2022-09-13T04:03:58","slug":"editable-and-uneditable-text-kbd-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/editable-and-uneditable-text-kbd-tutorial\/","title":{"rendered":"Editable and Uneditable Text kbd Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_within_div.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Editable and Uneditable Text kbd Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_within_divkbd.jpg\" title=\"Editable and Uneditable Text kbd Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Editable and Uneditable Text kbd Tutorial<\/p><\/div>\n<p>When we presented <a title='Editable and Uneditable Text Primer Tutorial' href='#eutpt'>Editable and Uneditable Text Primer Tutorial<\/a> &#8230;<\/p>\n<ul>\n<li>the first &#8220;highlighting of <i>not to be edited<\/i> text&#8221; idea was to use the HTML <a target=_blank title='HTML mark tag information from W3schools' href='https:\/\/www.w3schools.com\/jsref\/dom_obj_mark.asp'>mark<\/a> &#8230; and, today, we offer as an alternative way &#8230;<\/li>\n<li>the second &#8220;highlighting of <i>not to be edited<\/i> text&#8221; idea is to use the HTML <a target=_blank title='HTML kbd tag information from W3schools' href='https:\/\/www.w3schools.com\/jsref\/dom_obj_kbd.asp'>kbd<\/a><\/li>\n<\/ul>\n<p> &#8230; where the &#8220;kbd&#8221; HTML element type ensures display of text with a monospaced font (eg. Courier New), the font type where every character in the font is presented with the same width.  Do you remember us using a Courier New font based solution to formulating a very simple &#8220;twirler&#8221; that did not affect text to its right when we presented <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/ITblog\/image-pair-fitting-into-a-given-dimension-refresh-tutorial\/' title='Image Pair Fitting into a Given Dimension Refresh Tutorial'>Image Pair Fitting into a Given Dimension Refresh Tutorial<\/a>?   Thinking back, we could have applied a &#8220;kbd&#8221; solution here too.<\/p>\n<p>This &#8220;kbd&#8221; idea suits the Uneditable versus Editable Text aspects to <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_within_div.html-GETME\" title=\"div_within_div.html\">the changed<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_within_div.html-GETME\" title=\"div_within_div.html\">div_within_div.html<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_within_div.html\" title=\"Click picture\">live run<\/a>, but won&#8217;t suit aesthetically based projects, because it is quite offputing seeing text presented with a mix of monospaced and non monospaced text flowing through text sentences.<\/p>\n<p>THe simple changes to code can be categorized as &#8230;<\/p>\n<ul>\n<li>Javascript global var<font size=1>iables<\/font>, some <font color=blue>new<\/font> &#8230;<br \/>\n<code><br \/>\nvar aglow=' class=\"glow\"', bglow='';<br \/>\n<font color=blue>var eletype='mark';<\/font><br \/>\n<\/code>\n<\/li>\n<li>CSS <font color=blue>new styling<\/font> for &#8220;kbd&#8221; scenario &#8230;<br \/>\n<code><br \/>\n&lt;style&gt;<br \/>\n<br \/>\n\/* Thanks to https:\/\/www.w3schools.com\/howto\/tryit.asp?filename=tryhow_css_glowing_text *\/<br \/>\n<br \/>\n.glow {<br \/>\n  font-size: 16px;<br \/>\n  color: #fff;<br \/>\n  text-align: center;<br \/>\n  -webkit-animation: glow 1s ease-in-out infinite alternate;<br \/>\n  -moz-animation: glow 1s ease-in-out infinite alternate;<br \/>\n  animation: glow 1s ease-in-out infinite alternate;<br \/>\n  color: black;<br \/>\n}<br \/>\n<br \/>\n@-webkit-keyframes glow {<br \/>\n  from {<br \/>\n    text-shadow: 0 0 3px #fff, 0 0 5px #fff, 0 0 37px #e60073, 0 0 9px #e60073, 0 0 11px #e60073, 0 0 13px #e60073, 0 0 15px #e60073;<br \/>\n  }<br \/>\n<br \/> <br \/>\n  to {<br \/>\n    text-shadow: 0 0 24px #fff, 0 0 6px #ff4da6, 0 0 8px #ff4da6, 0 0 10px #ff4da6, 0 0 12px #ff4da6, 0 0 14px #ff4da6, 0 0 16px #ff4da6;<br \/>\n  }<br \/>\n}<br \/>\n<br \/>\n<font color=blue>.wolg {<br \/>\n  font-size: 16px;<br \/>\n  color: #fff;<br \/>\n  text-align: center;<br \/>\n  -webkit-animation: wolg 1s ease-in-out infinite alternate;<br \/>\n  -moz-animation: wolg 1s ease-in-out infinite alternate;<br \/>\n  animation: wolg 1s ease-in-out infinite alternate;<br \/>\n  color: black;<br \/>\n}<br \/>\n<br \/>\n@-webkit-keyframes wolg {<br \/>\n  from {<br \/>\n    text-shadow: 0 0 3px #fff, 0 0 5px #fff, 0 0 37px #6e0073, 0 0 9px #6e0073, 0 0 11px #6e0073, 0 0 13px #6e0073, 0 0 15px #6e0073;<br \/>\n  }<br \/>\n<br \/> <br \/>\n  to {<br \/>\n    text-shadow: 0 0 24px #fff, 0 0 6px #4dffa6, 0 0 8px #4dffa6, 0 0 10px #4dffa6, 0 0 12px #4dffa6, 0 0 14px #4dffa6, 0 0 16px #4dffa6;<br \/>\n  }<br \/>\n}<\/font><br \/>\n<br \/>\n&lt;\/style&gt;<br \/>\n<\/code>\n<\/li>\n<li>offering the user the choice via <font color=blue>new<\/font> HTML &#8230;<br \/>\n<code><br \/>\n&lt;h4&gt;Highlight<font color=blue>, via &lt;select id=selmark onchange=swap(this.value); size=2&gt;&lt;option value=mark selected&gt;mark&lt;\/option&gt;&lt;option value=kbd&gt;kbd&lt;\/option&gt;&lt;\/select&gt;<\/font> the parts you do not want to change, else add or change as required.&lt;\/h4&gt;<br \/>\n<\/code>\n<\/li>\n<li>different innerHTML definition for different mark vs kbd choice via <font color=blue>new<\/font> Javascript &#8230;<br \/>\n<code><br \/>\n    if (eval(1 + ilines) == lines.length && document.getElementById('phfloater')) {<br \/>\n <br \/>   document.getElementById('phfloater').innerHTML=document.getElementById('phfloater').innerHTML.replace(lines[ilines] + '', premark + '&lt;<font color=blue>' + eletype<\/font> + aglow + inmark + '&gt;' + lines[ilines] + '&lt;\/<font color=blue>' + eletype<\/font> + '&gt;' + postmark);<br \/>\n    } else if (document.getElementById('phfloater')) {<br \/>\n    document.getElementById('phfloater').innerHTML=document.getElementById('phfloater').innerHTML.replace(lines[ilines] + '&lt;br&gt;', premark + '&lt;<font color=blue>' + eletype<\/font> + aglow + inmark + '&gt;' + lines[ilines] + '&lt;\/<font color=blue>' + eletype<\/font> + '&gt;' + postmark + '&lt;br&gt;');<br \/>\n    }<br \/>\n<\/code>\n<\/li>\n<li>change existant innerHTML if mark vs kbd choice changes via Javascript &#8230;<br \/>\n<code><br \/>\nfunction swap(tv) {<br \/>\n  if (tv == 'mark') {<br \/>\n    eletype='mark';<br \/>\n    aglow=' class=\"glow\"';<br \/>\n    document.getElementById('phfloater').innerHTML=document.getElementById('phfloater').innerHTML.replace(\/\\&lt;\\\/kbd\/g, '&lt;\/mark').replace(\/\\&lt;kbd\/g, '&lt;mark').replace(\/wolg\/g, 'glow');<br \/>\n    document.getElementById('showhtml').innerHTML=document.getElementById('showhtml').innerHTML.replace(\/\\&lt;\\\/kbd\/g, '&lt;\/mark').replace(\/\\&lt;kbd\/g, '&lt;mark').replace(\/wolg\/g, 'glow');<br \/>\n  } else if (tv == 'kbd') {<br \/>\n    eletype='kbd';<br \/>\n    aglow=' class=\"wolg\"'<br \/>\n    document.getElementById('phfloater').innerHTML=document.getElementById('phfloater').innerHTML.replace(\/\\&lt;\\\/mark\/g, '&lt;\/kbd').replace(\/\\&lt;mark\/g, '&lt;kbd').replace(\/glow\/g, 'wolg');<br \/>\n    document.getElementById('showhtml').innerHTML=document.getElementById('showhtml').innerHTML.replace(\/\\&lt;\\\/mark\/g, '&lt;\/kbd').replace(\/\\&lt;mark\/g, '&lt;kbd').replace(\/glow\/g, 'wolg');<br \/>\n  }<br \/>\n}<br \/>\n<\/code>\n<\/li>\n<\/ul>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=_blank  href='\/\/www.rjmprogramming.com.au\/ITblog\/editable-and-uneditable-text-kbd-tutorial\/'>Editable and Uneditable Text kbd Tutorial<\/a>.<\/p-->\n<hr>\n<p id='eutpt'>Previous relevant <a target=_blank title='Editable and Uneditable Text Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/editable-and-uneditable-text-primer-tutorial\/'>Editable and Uneditable Text Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_within_div.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Editable and Uneditable Text Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_within_div.jpg\" title=\"Editable and Uneditable Text Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Editable and Uneditable Text Primer Tutorial<\/p><\/div>\n<p>We&#8217;ve become quite interested in the text editing control the recent &#8230;<\/p>\n<ul>\n<li>discovery in <a target=_blank title='Javascript Array Method Mobile Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/javascript-array-method-mobile-tutorial\/'>Javascript Array Method Mobile Tutorial<\/a> that a &#8220;button&#8221; (within a &#8220;div contenteditable=true&#8221;) could be coaxed into avoiding any mobile keyboard annoyances &#8230; via &#8230;<\/li>\n<li>different to today for &#8220;onclick&#8221; work set inner non-editable part to contenteditable=true (go figure) but, today, with the &#8220;text meets text&#8221; highlighting of non-editable parts that we allow the user to control &#8230;<\/li>\n<li>their inner non-editable parts to contenteditable=false (for both mobile and non-mobile &#8230; we&#8217;ve discovered today)<\/li>\n<\/ul>\n<p> &#8230; whereby editable and noneditable text can sit side by side within an HTML div contenteditable element &#8220;text <font size=1>editor<\/font> palette&#8221;.<\/p>\n<p>We &#8220;glow&#8221; and &#8220;mark&#8221; (about which you should read our <a target=_blank title='HTML5 Mark Tag with Glowing Text Tutorial' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/html5-mark-tag-with-glowing-text-tutorial\/'>HTML5 Mark Tag with Glowing Text Tutorial<\/a>) the uneditable bits the user highlights in addition to the &#8230;<\/p>\n<blockquote><p>\nYours sincerely,<br \/>\n<br \/>\nRJM Programming\n<\/p><\/blockquote>\n<p> &#8230; we start out making uneditable (but no &#8220;glow&#8221; nor &#8220;mark&#8221; here) you can try for yourself with today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_within_div.html_GETME\" title=\"div_within_div.html\">div_within_div.html<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_within_div.html\" title=\"Click picture\">live run<\/a> &#8230;<\/p>\n<p><iframe src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/div_within_div.html\" style=\"width:100%;height:900px;\"><\/iframe><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d50446' onclick='var dv=document.getElementById(\"d50446\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/contenteditable\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d50446' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d55818' onclick='var dv=document.getElementById(\"d55818\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/monospaced\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d55818' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>When we presented Editable and Uneditable Text Primer Tutorial &#8230; the first &#8220;highlighting of not to be edited text&#8221; idea was to use the HTML mark &#8230; and, today, we offer as an alternative way &#8230; the second &#8220;highlighting of &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/editable-and-uneditable-text-kbd-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[2442,281,3433,2349,576,652,3979,2165,2997,997,1254,1319],"class_list":["post-55818","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-contenteditable","tag-css","tag-editable","tag-highlight","tag-html","tag-javascript","tag-kbd","tag-mark","tag-monospaced","tag-programming","tag-text","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/55818"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=55818"}],"version-history":[{"count":6,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/55818\/revisions"}],"predecessor-version":[{"id":55824,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/55818\/revisions\/55824"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=55818"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=55818"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=55818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}