Role of Keyboard Event altKey Property in JavaScript

Daniol Thomas
Updated on 23-May-2020 11:00:45

164 Views

The altkey property is used to show whether ALT key is pressed or not when key event was triggered.ExampleYou can try to run the following code to learn how to implement altKey property in JavaScript.                 Press any key                function funcAltKey(event) {             var val = document.getElementById("res");                         if (event.altKey) {                val.innerHTML = "ALT key: Pressed";             } else {                val.innerHTML = "ALT key: NOT Pressed";             }          }          

Usage of copyWithin Method in JavaScript

Nikitha N
Updated on 23-May-2020 11:00:01

186 Views

Use the copyWithin() method in JavaScript to copy array elements. You can set the index from/to where (index) the elements are copied. The following are the elements supported by JavaScript.target − The position of the index from where the elements is to be copied.begin − The index to start copying the element. This is an optional parameter.end − The index to end copying the element. This is an optional parameter.ExampleYou can try to run the following code to learn how to work with copyWithin() method in JavaScript.                    var num ... Read More

Enable or Disable GPS Programmatically on Kotlin

Azhar
Updated on 23-May-2020 10:59:06

2K+ Views

This example demonstrates how to enable or disable the GPS programmatically on Kotlin.Step 1 − Create a new project in Android Studio, go to File ? New Project and fill all required details to create a new project.Step 2 &minsu; Add the following code to res/layout/activity_main.xml.Example             Step 3 − Add the following code to src/MainActivity.ktimport android.content.Context import android.content.Intent import android.location.LocationManager import android.os.Bundle import android.provider.Settings import android.view.View import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private lateinit var context: Context    var intent1: Intent? = null    lateinit var textView: TextView   ... Read More

Load Image by URL using Picasso Library in Kotlin

Azhar
Updated on 23-May-2020 10:50:48

2K+ Views

This example demonstrates how to create a WebView in an Android App using Kotlin.Step 1 − Create a new project in Android Studio, go to File ? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example             Step 3 − Add the following dependency to build.gradle(Module:app)implementation 'com.squareup.picasso:picasso:2.5.2'Step 4 − Add the following code to src/MainActivity.ktExampleimport android.os.Bundle import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity import com.squareup.picasso.Picasso class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       ... Read More

Create ListView with Checkbox in Kotlin

Azhar
Updated on 23-May-2020 10:44:43

1K+ Views

This example demonstrates how to Create a listView with a checkBox in Kotlin.Step 1  − Create a new project in Android Studio, go to File ? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktExampleimport android.view.View import android.widget.AdapterView.OnItemClickListener import android.widget.ListView import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity() {    private var dataModel: ArrayList? = null    private lateinit var listView: ListView    private lateinit var adapter: CustomAdapter    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState) ... Read More

Create WebView in an Android App using Kotlin

Azhar
Updated on 23-May-2020 10:43:11

2K+ Views

This example demonstrates how to create a WebView in an Android App using Kotlin.Step 1 − Create a new project in Android Studio, go to File ? New Project and fill all required details to create a new project.Example         Step 3 − Add the following code to src/MainActivity.ktExampleimport android.os.Bundle import android.webkit.WebView import android.webkit.WebViewClient import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private val webView: WebView? = null    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val webView = findViewById(R.id.webView)       ... Read More

What Happens When is Converted to String in JavaScript

Arushi
Updated on 23-May-2020 10:16:37

143 Views

Use the String() method in JavaScript to convert to String. You can try to run the following code to learn how to convert { } to String in JavaScript.ExampleLive Demo           Convert {} to String                var myVal = {};          document.write("String: " + String(myVal));          

How 'is' Converted to Boolean in JavaScript

Lakshmi Srinivas
Updated on 23-May-2020 10:09:15

168 Views

Use the Boolean() method in JavaScript to convert to Boolean. You can try to run the following code to learn how to convert [ ] to Boolean in JavaScript.ExampleLive Demo           Convert [] to Boolean                var myVal = [];          document.write("Boolean: " + Boolean(myVal));          

Set Shape of Border in Top Right Corner with JavaScript

Fendadis John
Updated on 23-May-2020 10:08:48

236 Views

To set the shape of the border of the top-right corner in JavaScript, use the borderTopRightRadius property. Set border radius using this property.ExampleYou can try to run the following code to learn how to set the shape of the top-right border with JavaScript.Live Demo                    #box {             border: thick solid gray;             width: 300px;             height: 200px          }                     Demo Text             Change top right border radius                function display() {             document.getElementById("box").style.borderTopRightRadius = "20px";          }          

Role of Keyboard Event shiftKey Property in JavaScript

Alankritha Ammu
Updated on 23-May-2020 10:08:04

141 Views

The altkey property is used to show whether SHIFT key is pressed or not when key event was triggered.ExampleYou can try to run the following code to learn how to implement shiftKey property in JavaScript.                 Press any key                function funcShiftKey(event) {             var val = document.getElementById("res");             if (event.shiftKey) {                val.innerHTML = "SHIFT key: Pressed";             } else {                val.innerHTML = "SHIFT key: NOT Pressed";             }          }          

Advertisements