{"id":4893,"date":"2018-12-13T23:41:20","date_gmt":"2018-12-13T15:41:20","guid":{"rendered":"https:\/\/unitycoder.com\/blog\/?p=4893"},"modified":"2018-12-13T23:41:20","modified_gmt":"2018-12-13T15:41:20","slug":"adding-multiple-submit-keys-to-input-manager","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2018\/12\/13\/adding-multiple-submit-keys-to-input-manager\/","title":{"rendered":"Adding Multiple Submit Keys to Input Manager"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4894\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2018\/12\/13\/adding-multiple-submit-keys-to-input-manager\/input-manager-duplicate-array\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2018\/12\/input-manager-duplicate-array.png?fit=327%2C86&amp;ssl=1\" data-orig-size=\"327,86\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"input-manager-duplicate-array\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2018\/12\/input-manager-duplicate-array.png?fit=327%2C86&amp;ssl=1\" class=\"alignnone size-full wp-image-4894\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2018\/12\/input-manager-duplicate-array.png?resize=327%2C86&#038;ssl=1\" alt=\"\" width=\"327\" height=\"86\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2018\/12\/input-manager-duplicate-array.png?w=327&amp;ssl=1 327w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2018\/12\/input-manager-duplicate-array.png?resize=300%2C79&amp;ssl=1 300w\" sizes=\"auto, (max-width: 327px) 100vw, 327px\" \/><\/p>\n<p>Had to make an UI button clickable by multiple different keyboard keys (like enter, space, left\/right shift etc.)<br \/>\nAnd almost started writing custom script to handle extra keys when selecting UI button..<\/p>\n<p>but then realized that you can duplicate Input Manager keys, and sure enough it works!<br \/>\n(see image above, you can right click to duplicate, then set new keys to it)<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4895\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2018\/12\/13\/adding-multiple-submit-keys-to-input-manager\/multiple-submit-keys\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2018\/12\/multiple-submit-keys.png?fit=424%2C872&amp;ssl=1\" data-orig-size=\"424,872\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"multiple-submit-keys\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2018\/12\/multiple-submit-keys.png?fit=424%2C872&amp;ssl=1\" class=\"alignnone size-full wp-image-4895\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2018\/12\/multiple-submit-keys.png?resize=424%2C872&#038;ssl=1\" alt=\"\" width=\"424\" height=\"872\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2018\/12\/multiple-submit-keys.png?w=424&amp;ssl=1 424w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2018\/12\/multiple-submit-keys.png?resize=146%2C300&amp;ssl=1 146w\" sizes=\"auto, (max-width: 424px) 100vw, 424px\" \/><\/p>\n<p>&#8212;<\/p>\n<p>For the button i attached this init script, to make it selected (and highlighted) at start.<br \/>\n(otherwise user needs to select it manually first, before can click it, with controller for example)<\/p>\n<style>.gist table { margin-bottom: 0; }<\/style>\n<div style=\"tab-size: 8\" id=\"gist25141291\" class=\"gist\">\n<div class=\"gist-file\" translate=\"no\" data-color-mode=\"light\" data-light-theme=\"light\">\n<div class=\"gist-data\">\n<div class=\"js-gist-file-update-container js-task-list-container\">\n<div id=\"file-initbutton-cs\" class=\"file my-2\">\n<div itemprop=\"text\"\n      class=\"Box-body p-0 blob-wrapper data type-c  \"\n      style=\"overflow: auto\" tabindex=\"0\" role=\"region\"\n      aria-label=\"InitButton.cs content, created by unitycoder on 11:57AM on August 08, 2015.\"\n    ><\/p>\n<div class=\"js-check-hidden-unicode js-blob-code-container blob-code-content\">\n<p>  <template class=\"js-file-alert-template\"><\/p>\n<div data-view-component=\"true\" class=\"flash flash-warn flash-full d-flex flex-items-center\">\n  <svg aria-hidden=\"true\" data-component=\"Octicon\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n    <span><br \/>\n      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.<br \/>\n      <a class=\"Link--inTextBlock\" href=\"https:\/\/github.co\/hiddenchars\" target=\"_blank\">Learn more about bidirectional Unicode characters<\/a><br \/>\n    <\/span><\/p>\n<div data-view-component=\"true\" class=\"flash-action\">        <a href=\"{{ revealButtonHref }}\" data-view-component=\"true\" class=\"btn-sm btn\">    Show hidden characters<br \/>\n<\/a>\n<\/div>\n<\/div>\n<p><\/template><br \/>\n<template class=\"js-line-alert-template\"><br \/>\n  <span aria-label=\"This line has hidden Unicode characters\" data-view-component=\"true\" class=\"line-alert tooltipped tooltipped-e\"><br \/>\n    <svg aria-hidden=\"true\" data-component=\"Octicon\" height=\"16\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" data-view-component=\"true\" class=\"octicon octicon-alert\">\n    <path d=\"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z\"><\/path>\n<\/svg><br \/>\n<\/span><\/template><\/p>\n<table data-hpc class=\"highlight tab-size js-file-line-container\" data-tab-size=\"4\" data-paste-markdown-skip data-tagsearch-path=\"InitButton.cs\">\n<tr>\n<td id=\"file-initbutton-cs-L1\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"1\"><\/td>\n<td id=\"file-initbutton-cs-LC1\" class=\"blob-code blob-code-inner js-file-line\">using UnityEngine;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L2\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"2\"><\/td>\n<td id=\"file-initbutton-cs-LC2\" class=\"blob-code blob-code-inner js-file-line\">using UnityEngine.UI;<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L3\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"3\"><\/td>\n<td id=\"file-initbutton-cs-LC3\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L4\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"4\"><\/td>\n<td id=\"file-initbutton-cs-LC4\" class=\"blob-code blob-code-inner js-file-line\">\/\/ makes button selected at Start (to force Highlighted color on it)<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L5\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"5\"><\/td>\n<td id=\"file-initbutton-cs-LC5\" class=\"blob-code blob-code-inner js-file-line\">\/\/ this is required to allow pressing Fire \/ Submit key to press button (without having to select button first)<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L6\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"6\"><\/td>\n<td id=\"file-initbutton-cs-LC6\" class=\"blob-code blob-code-inner js-file-line\">\n<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L7\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"7\"><\/td>\n<td id=\"file-initbutton-cs-LC7\" class=\"blob-code blob-code-inner js-file-line\">public class InitButton : MonoBehaviour <\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L8\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"8\"><\/td>\n<td id=\"file-initbutton-cs-LC8\" class=\"blob-code blob-code-inner js-file-line\">{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L9\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"9\"><\/td>\n<td id=\"file-initbutton-cs-LC9\" class=\"blob-code blob-code-inner js-file-line\">\tvoid Start () <\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L10\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"10\"><\/td>\n<td id=\"file-initbutton-cs-LC10\" class=\"blob-code blob-code-inner js-file-line\">\t{<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L11\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"11\"><\/td>\n<td id=\"file-initbutton-cs-LC11\" class=\"blob-code blob-code-inner js-file-line\">        if (GetComponent&lt;Button&gt;())<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L12\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"12\"><\/td>\n<td id=\"file-initbutton-cs-LC12\" class=\"blob-code blob-code-inner js-file-line\">        {<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L13\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"13\"><\/td>\n<td id=\"file-initbutton-cs-LC13\" class=\"blob-code blob-code-inner js-file-line\">            GetComponent&lt;Button&gt;().Select();<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L14\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"14\"><\/td>\n<td id=\"file-initbutton-cs-LC14\" class=\"blob-code blob-code-inner js-file-line\">            Destroy(this);<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L15\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"15\"><\/td>\n<td id=\"file-initbutton-cs-LC15\" class=\"blob-code blob-code-inner js-file-line\">        }<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L16\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"16\"><\/td>\n<td id=\"file-initbutton-cs-LC16\" class=\"blob-code blob-code-inner js-file-line\">    }<\/td>\n<\/tr>\n<tr>\n<td id=\"file-initbutton-cs-L17\" class=\"blob-num js-line-number js-blob-rnum\" data-line-number=\"17\"><\/td>\n<td id=\"file-initbutton-cs-LC17\" class=\"blob-code blob-code-inner js-file-line\">}<\/td>\n<\/tr>\n<\/table>\n<\/div><\/div>\n<\/p><\/div>\n<\/div><\/div>\n<div class=\"gist-meta\">\n        <a href=\"https:\/\/gist.github.com\/unitycoder\/10805d820bea9f78259e\/raw\/a8a8dc1b549fa6652b032fd02e7cc2fb33574fb6\/InitButton.cs\" style=\"float:right\" class=\"Link--inTextBlock\">view raw<\/a><br \/>\n        <a href=\"https:\/\/gist.github.com\/unitycoder\/10805d820bea9f78259e#file-initbutton-cs\" class=\"Link--inTextBlock\"><br \/>\n          InitButton.cs<br \/>\n        <\/a><br \/>\n        hosted with &#10084; by <a class=\"Link--inTextBlock\" href=\"https:\/\/github.com\">GitHub<\/a>\n      <\/div>\n<\/p><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Had to make an UI button clickable by multiple different keyboard keys (like enter, space, left\/right shift etc.) And almost started writing custom script to handle extra keys when selecting UI button.. but then realized that you can duplicate Input Manager keys, and sure enough [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4894,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Adding Multiple Submit Keys for UI with Input Manager","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[797,3],"tags":[999,1075,820,1077,908,1076],"class_list":["post-4893","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips","category-unity3d","tag-button","tag-input-manager","tag-keys","tag-multiple","tag-selected","tag-submit"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2018\/12\/input-manager-duplicate-array.png?fit=327%2C86&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-1gV","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4893","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=4893"}],"version-history":[{"count":1,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4893\/revisions"}],"predecessor-version":[{"id":4896,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4893\/revisions\/4896"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/4894"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=4893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=4893"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=4893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}