The Simple Web (Copy 14664)
✨ นายนนทพัทธ์ จิ๋วน๊อต
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Redressed&display=swap" rel="stylesheet"> <div class="text"> <p>Press "C" to Call.</p> <p>Press "V" to Hang up.</p> <p>Press "S" to Start.</p> <P>Press "Number" to sound</P> </div> <div class="audio"> <div class="outlay"> <div class="button-num"> <button id="key_1" class="but-in" onclick="note(261)">1</button> <button id="key_2" class="but-in" onclick="note(261)">2</button> <button id="key_3" class="but-in" onclick="note(261)">3</button><br> <button id="key_4" class="but-in" onclick="note(261)">4</button> <button id="key_5" class="but-in" onclick="note(261)">5</button> <button id="key_6" class="but-in" onclick="note(261)">6</button><br> <button id="key_7" class="but-in" onclick="note(261)">7</button> <button id="key_8" class="but-in" onclick="note(261)">8</button> <button id="key_9" class="but-in" onclick="note(261)">9</button><br> <button id="key_0" class="but-in" onclick="note(261)">0</button> <button class="but-in" onclick="note(261)">*</button> <button class="but-in" onclick="note(261)">#</button><br><br> <button id="key_call" class="but-call" onclick="gain.gain.value = 1">📞</button> <button id="key_hang" class="but-out" onclick="gain.gain.value = 0">☎️</button> </div> <button id="key_start" class="but-start" onclick="osci.start()">♢</button> <div class="fakebut"></div> </div> </div> <style> body{ background: linear-gradient(0.25turn,rgb(191, 255, 240), #ebf8e1, rgb(240, 255, 194)); place-items: center; text-align: center; } /* button style */ .outlay{ margin-top: 10%; max-width: 100%; max-height: 100%; padding: 1em; margin-bottom: 25%; margin-right: 35%; margin-left: 35%; background: rgb(25, 27, 27); border-radius: 15px; } .button-num{ margin-top: 10%; max-width: 100%; max-height: 100%; padding: 2em; margin-top: 10%; margin-bottom: 20%; margin-right: 10%; margin-left: 10%; background: hsl(199.2, 77.4%, 73.9%); text-align: center; place-items: center; } .but-in{ margin-top: 15px; color: rgb(20, 22, 22); background: rgb(236, 231, 231); padding: 20px; border-radius: 50%; cursor: pointer; } .but-call{ margin-top: 15px; background: rgb(168, 231, 19); padding: 18px; font-size: 1.5em; border-radius: 50%; margin-right: 50px; cursor: pointer; } .but-out{ margin-top: 15px; background: rgb(245, 190, 11); padding: 18px; font-size: 1.5em; border-radius: 50%; cursor: pointer; } .but-start{ margin-top: -30px; margin-bottom: 15px; background: rgb(243, 242, 240); padding: 18px; font-size: 1.5em; border-radius: 25%; cursor: pointer; } .fakebut{ background: rgb(168, 231, 19); padding: 18px; } /* Text edit */ .text{ font-family: 'Redressed', cursive; margin-top: 20px; font-size: 2em; } </style> <script> let isStart = 0; audio = new (window.AudioContext || window.webkitAudioContext)() osci = audio.createOscillator() gain = audio.createGain() osci.connect(gain) gain.connect(audio.destination) function frequency1(num){ num = parseInt(num) console.log(num) osci.frequency.value = num } function volume(num){ num = parseInt(num) num = num/100 gain.gain.value = num } function note(s){ console.log(s) let time = audio.currentTime let note_osci = audio.createOscillator() let note_gain = audio.createGain() note_osci.connect(note_gain) note_gain.connect(audio.destination) note_osci.start() note_gain.gain.value = 1; note_gain.gain.linearRampToValueAtTime(0, time+.7) } document.body.onkeydown = function(keyclick){ let key = event.key console.log(keyclick.key) if(key == '1'){ key_1.click() } if(key == '2'){ key_2.click() } if(key == '3'){ key_3.click() } if(key == '4'){ key_4.click() } if(key == '5'){ key_5.click() } if(key == '6'){ key_6.click() } if(key == '7'){ key_8.click() } if(key == '8'){ key_8.click() } if(key == '9'){ key_9.click() } if(key == '1'){ key_1.click() } if(key == '0'){ key_0.click() } if(key == 'C' || key == 'c'){ key_call.click() } if(key == 'V' || key == 'v'){ key_hang.click() } if(key == 'S' || key == 's'){ key_start.click() } } </script>